Pelles C forum
Pelles C => Bug reports => Topic started by: JohnF on October 26, 2010, 09:22:33 AM
-
I've tried this with two other compilers which both give the correct time. It was ok until recently, it looks like the clock has gone back early by 1 hour.
#include <stdio.h>
#include <time.h>
int main(void)
{
time_t now = time(NULL);
struct tm * ltm = localtime(&now);
printf("%0.2d:%0.2d:%0.2d\n",
ltm->tm_hour,
ltm->tm_min,
ltm->tm_sec);
return 0;
}
John
-
daylight saving is 0 ???
#include <stdio.h>
#include <time.h>
int main(void)
{
time_t now = time(NULL);
struct tm * ltm = localtime(&now);
printf("%0.2d:%0.2d:%0.2d %d\n",
ltm->tm_hour,
ltm->tm_min,
ltm->tm_sec,
ltm->tm_isdst);
return 0;
}
http://24timezones.com (http://24timezones.com)
-
Yes, clocks should go back an hour on the last Sunday in October.
John
-
Yes, clocks should go back an hour on the last Sunday in October.
John
Except in Canada and the USA where it's the second sunday in March until the first Sunday in November.
-
Yes, clocks should go back an hour on the last Sunday in October.
John
Except in Canada and the USA where it's the second sunday in March until the first Sunday in November.
I don't live in either of those places! :)
John
-
I don't live in either of those places! :)
John
Unfortunately, I do.
-
AFAIK, nothing directly changed in this area for a long time. I get the same (wrong) result with 6.0. I need to investigate...
-
AFAIK, nothing directly changed in this area for a long time. I get the same (wrong) result with 6.0. I need to investigate...
Thanks.
John
-
I don't know, if it help anyone, but GetLocalTime() seems to work correct for me.
#include <windows.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
SYSTEMTIME lt;
GetLocalTime(<);
printf("%4d-%02d-%02d %2d:%02d:%02d\n",
lt.wYear, lt.wMonth, lt.wDay,
lt.wHour, lt.wMinute, lt.wSecond);
return 0;
}
-
I think, it must be an error in Pelles runtime library, because if you link to the program the library msvcrt.lib the result is correct for me.
-
The assembly translation below is linked against msvcrt.lib and works fine :
.386
.model flat,stdcall
option casemap:none
include LocalTime.inc
.data
msg db '%4d-%02d-%02d %2d:%02d:%02d',13,10,0
.code
start:
call main
invoke ExitProcess,0
main PROC USES esi
LOCAL LocalTime:SYSTEMTIME
lea esi,LocalTime
invoke GetLocalTime,esi
invoke printf,ADDR msg,\
SYSTEMTIME.wYear[esi], SYSTEMTIME.wMonth[esi],\
SYSTEMTIME.wDay[esi],SYSTEMTIME.wHour[esi],\
SYSTEMTIME.wMinute[esi],SYSTEMTIME.wSecond[esi]
ret
main ENDP
END start
-
It was a problem with GetTimeZoneInformation(), day-in-month format, and the fact that DST ends in Europe on the 31st (October) this year. Should be fixed now (time zones in Windows is a royal mess, so you never really know...).
-
Another version linked against pocrt.lib