Message233259
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. |
|
Date |
User |
Action |
Args |
2014-12-31 18:05:48 | belopolsky | set | recipients:
+ belopolsky, lemburg, serhiy.storchaka, jamercee, Saimadhav.Heblikar, torm |
2014-12-31 18:05:48 | belopolsky | set | messageid: <1420049148.22.0.159331209677.issue23136@psf.upfronthosting.co.za> |
2014-12-31 18:05:48 | belopolsky | link | issue23136 messages |
2014-12-31 18:05:47 | belopolsky | create | |
|