Discussion:
[ast-developers] Daylight savings time bug strftime
EDGAR, ADAM (ADAM)
2016-03-21 21:45:12 UTC
Permalink
We’ve come across an apparent bug in the AST version of strftime in the current beta. The hour you skip ahead in the spring is not handle properly when set to time zones that do not use DST such as UTC (used by gmtime_r below). This is the tiny example I’ve come up with:

$ cat strftime_test.c
#include <ast.h>
#include <time.h>

int main( int argc, char *argv[] ){
time_t AM1=1457834400-60*60;
time_t AM2=1457834400; /* the hour we jump ahead in DST */
time_t AM3=1457834400+60*60;
struct tm *t,tbuf;
char buf[SF_BUFSIZE];
t = gmtime_r(&AM1,&tbuf);
strftime(buf, SF_BUFSIZE, "%Y %m %d %H", t);
printf("1AM UTC = %s\n", buf);
t = gmtime_r(&AM2,&tbuf);
strftime(buf, SF_BUFSIZE, "%Y %m %d %H", t);
printf("2AM UTC = %s\n", buf);
t = gmtime_r(&AM3,&tbuf);
strftime(buf, SF_BUFSIZE, "%Y %m %d %H", t);
printf("3AM UTC = %s\n", buf);

return 0;
}
$ gcc -Wall -I/opt/ast/include/ast strftime_test.c -o strftime_test /opt/ast/lib/libast.a
$ ./strftime_test
1AM UTC = 2016 03 13 01
2AM UTC = 2016 03 13 01
3AM UTC = 2016 03 13 03



As you can see the second output is not 02:00 as expected. We’ve found one odd line that may explain it libast/tm/tmxtime.c:99 may need a second = sign.

ASE

Loading...