This is the mail archive of the
mailing list for the glibc project.
Re: Different unixtimes, same localtime
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Dario Teixeira <dario dot teixeira at nleyten dot com>
- Cc: libc-help at sourceware dot org
- Date: Tue, 08 Nov 2016 21:22:35 +0100
- Subject: Re: Different unixtimes, same localtime
- Authentication-results: sourceware.org; auth=none
- References: <firstname.lastname@example.org>
* Dario Teixeira:
> Either I've found a bug in localtime_r or I'm missing
> something about its usage (probably the latter).
> The problem is that I'm getting the exact same tm structure
> for invocations of localtime_r with different Unix times.
> Now, the times I'm using are special in that they represent
> the same localtime in the provided locale. Nevertheless,
> the smaller one (212541000L) happened when DST was in effect,
> whereas the second one (212544600L) happened one hour later
> was DST was no longer in effect. Shouldn't this difference
> be signaled in the tm_isdst field?
I think the changing offset to UTC is not due to a DST change, but a
time zone change for Europe/Lisbon:
fw@deneb:~$ zdump -v Europe/Lisbon | grep 1976
Europe/Lisbon Sat Sep 25 23:59:59 1976 UT = Sun Sep 26 00:59:59 1976 CET isdst=0 gmtoff=3600
Europe/Lisbon Sun Sep 26 00:00:00 1976 UT = Sun Sep 26 00:00:00 1976 WET isdst=0 gmtoff=0
>From the tzdata/europe source file:
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Europe/Lisbon -0:36:45 - LMT 1884
-0:36:45 - LMT 1912 Jan 1 # Lisbon Mean Time
0:00 Port WE%sT 1966 Apr 3 2:00
1:00 - CET 1976 Sep 26 1:00
0:00 Port WE%sT 1983 Sep 25 1:00s
0:00 W-Eur WE%sT 1992 Sep 27 1:00s
1:00 EU CE%sT 1996 Mar 31 1:00u
0:00 EU WE%sT
So I would say that localtime_r gives the right result.