1

I'm working a RTC and want to use glibc to get correct time. I am in Sydney and the DST time occurs at Oct first Sun 2am & Apr first Sun 2am. E.g. On 2020 Apr 5, 1:59:59 -> 2:00:00 -> 2:59:59 -> 2:00:00 -> 2:59:59 -> 3:00:00 I use functions : time(), localtime(), gmtime() to check if the intput time is valid. But I got some weird result.

input=5/04/2020 1:34:56, t=1586010896
localtime=5/04/2020 1:34:56
gmtime=4/04/2020 14:34:56

input=5/04/2020 2:34:56, t=1586014496
localtime=5/04/2020 2:34:56
gmtime=4/04/2020 15:34:56

input=5/04/2020 3:34:56, t=1586018096
localtime=5/04/2020 2:34:56
gmtime=4/04/2020 16:34:56

input=5/04/2020 4:34:56, t=1586025296
localtime=5/04/2020 4:34:56
gmtime=4/04/2020 18:34:56

The input "5/04/2020 2:34:56" is a confusing, because there are two "2:00:00-2:59:59". The localtime() gave me 2:34:56

when I intput 5/04/2020 3:34:56, the local time should be 3:34:56. But localtime() gave me 2:34:56 and the UTC time 17:xx:xx disappeared.

Can't understand that.

char990
  • 11
  • 1

0 Answers0