This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xtreak
Recipients belopolsky, hywl51, jeffknupp, p-ganssle, xtreak
Date 2018-12-19.18:31:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1545244271.95.0.788709270274.issue29081@psf.upfronthosting.co.za>
In-reply-to
Content
This causes the round trip to be a ValueError. 

./python.exe
Python 3.8.0a0 (heads/master:1dd035954b, Dec 18 2018, 10:12:34)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> value = '2016 51 0'
>>> format = '%Y %W %w'
>>> time.strftime(format, time.strptime('2016 51 0', format)) == value
True
>>> time.strptime('2016 52 0', format)
time.struct_time(tm_year=2017, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=6, tm_yday=367, tm_isdst=-1)
>>> time.strftime(format, time.strptime('2016 52 0', format)) == value
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: day of year out of range

On Ruby this causes runtime error

irb(main):005:0> DateTime::strptime("2016 52 0", "%Y %W %w")
Traceback (most recent call last):
        3: from /usr/local/bin/irb:11:in `<main>'
        2: from (irb):5
        1: from (irb):5:in `strptime'
ArgumentError (invalid date)

With C it returns 2016 00 5 on Mac OS 10.10.4 and 2017 00 0 on Ubuntu

#include <stdio.h>
#include <time.h>

int main() {
  struct tm ltm = {0};
  char buf[] = "2016 52 0";
  strptime(buf, "%Y %W %w", &ltm);
  time_t ptm = mktime(&ltm);

  printf("tm year %d\n", ltm.tm_year);
  printf("tm yday %d\n", ltm.tm_yday);
  printf("tm wday %d\n", ltm.tm_wday);

  char str[50];
  struct tm *tm_info = localtime(&ptm);
  strftime(str, 50, "%Y %W %w", tm_info);
  printf("%s\n", str);
}

Output : 

Mac

tm year 116
tm yday 0
tm wday 5
2016 00 5

Ubuntu 

tm year 117
tm yday 0
tm wday 0
2017 00 0
History
Date User Action Args
2018-12-19 18:31:12xtreaksetrecipients: + xtreak, belopolsky, jeffknupp, p-ganssle, hywl51
2018-12-19 18:31:11xtreaksetmessageid: <1545244271.95.0.788709270274.issue29081@psf.upfronthosting.co.za>
2018-12-19 18:31:11xtreaklinkissue29081 messages
2018-12-19 18:31:11xtreakcreate