Message261024
| Author |
gregory.p.smith |
| Recipients |
Sriram Rajagopalan, gregory.p.smith |
| Date |
2016年02月29日.21:26:32 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1456781193.02.0.504000860673.issue26460@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Python's time.strptime() behavior is consistent with that of glibc 2.19:
======= strptime_c.c =======
#define _XOPEN_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int
main(void)
{
struct tm tm;
char buf[255];
memset(&tm, 0, sizeof(struct tm));
strptime("Feb 29", "%b %d", &tm);
strftime(buf, sizeof(buf), "%d %b %Y %H:%M", &tm);
puts(buf);
exit(EXIT_SUCCESS);
}
=======
$ gcc strptime_c.c
$ ./a.out
29 Feb 1900 00:00
I'm not saying that the behavior is a good API, but given the unfortunate API at hand, parsing a date without specifying what year it is using strptime is a bad idea. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2016年02月29日 21:26:33 | gregory.p.smith | set | recipients:
+ gregory.p.smith, Sriram Rajagopalan |
| 2016年02月29日 21:26:33 | gregory.p.smith | set | messageid: <1456781193.02.0.504000860673.issue26460@psf.upfronthosting.co.za> |
| 2016年02月29日 21:26:32 | gregory.p.smith | link | issue26460 messages |
| 2016年02月29日 21:26:32 | gregory.p.smith | create |
|