Alexander Belopolsky added the comment:

I would prefer to accept "denormalized" "%Y %W %w" combinations.  Note that 
while Mac OSX and glibc versions of strptime produce different results, neither 
implementation signals an error by returning NULL.

> In C the strptime function doesn't return valid date for such input.

This is not true.  In C, struct tm is not required to contain normalized data.  
I am attaching a modified version of Serhiy's strptimetest.c:

$ diff -u strptimetest.c strptimetest2.c
--- strptimetest.c      2014-12-30 13:45:17.000000000 -0500
+++ strptimetest2.c     2014-12-31 12:56:17.000000000 -0500
@@ -16,6 +16,7 @@
         exit(1);
     }
     strptime(argv[1], argv[2], &tm);
+    mktime(&tm);
     strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tm);
     puts(buf);
     return 0;

With this modification, I get on Linux

$ ./a.out "0 2015 2" "%W %Y %w"
2014-11-29 00:00:00

which is still wrong, but I think this is a glibc issue: mktime accepted 
strptime result as valid even though it failed to normalize it correctly.

----------
Added file: http://bugs.python.org/file37576/strptimetest2.c

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23136>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to