[issue35841] Datetime strftime() does not return correct week numbers for 2019

2019-01-28 Thread Tommy Rowland

New submission from Tommy Rowland :

This relates to the calculation of the week number from a given datetime, when 
calling the strftime method. If you call isocalendar() on the datetime.datetime 
object for the date ‘2018-12-31’, the week number returned is 1, which is 
correct. This is the same when checking the week attribute for the pandas 
timestamp equivalent. However, when you call strftime on this object (either 
datetime or timestamp), passing the ‘%W’ offset string, it returns 53, and then 
returns 00 for the remainder of the week. It seems that the rest of the weeks 
in 2019 are out by 1 when returned using this function. This issue seems to be 
present with the strptime function also.

--
components: Extension Modules, Windows
files: Python Datetime Issue.JPG
messages: 334462
nosy: paul.moore, steve.dower, tim.golden, tr12, zach.ware
priority: normal
severity: normal
status: open
title: Datetime strftime() does not return correct week numbers for 2019
type: behavior
versions: Python 2.7, Python 3.6
Added file: https://bugs.python.org/file48083/Python Datetime Issue.JPG

___
Python tracker 
<https://bugs.python.org/issue35841>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35841] Datetime strftime() does not return correct week numbers for 2019

2019-01-29 Thread Tommy Rowland


Tommy Rowland  added the comment:

Hi Paul,

Thank you for the clarification. I can see that %V does indeed return the
correct week number. It seems that when calling strftime, it is possible to
use this in conjunction with %y, but when calling strptime, it is not. Is
this also intended behaviour?

Best regards,

Tommy

On Mon, Jan 28, 2019 at 4:44 PM Paul Ganssle  wrote:

>
> Paul Ganssle  added the comment:
>
> I think this is not a bug. bpo-35535 is probably also intended behavior,
> but that is less certain.
>
> The misunderstanding here is that %W does not give you the ISO week
> number, from the documentation:
>
> %W: Week number of the year (Monday as the first day of the week) as a
> decimal number.
> All days in a new year preceding the first Monday are considered
> to be in week 0.
>
>
> If you want the ISO week number, I think you need %V, which *is* the ISO
> week:
>
> >>> datetime(2018, 12, 31).strftime("%V %W")
>
> '01 53'
>
> I believe this ticket can be closed.
>
> --
>
> ___
> Python tracker 
> <https://bugs.python.org/issue35841>
> ___
>

--

___
Python tracker 
<https://bugs.python.org/issue35841>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com