Message261024
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. |
|
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 | |
|