Public bug reported:

Release: 9.10
Version: libc6 2.10.1-0ubuntu16

The following testcase (also attached):

#include <stdio.h>
#include <time.h>
#include <locale.h>

int main(void)
{
        time_t t;

        tzset();
        printf("tzname: (%s,%s)  timezone: %ld  daylight:%d\n",
                        tzname[0], tzname[1], timezone, daylight);
        time(&t);
        localtime(&t);
        printf("tzname: (%s,%s)  timezone: %ld  daylight:%d\n",
                        tzname[0], tzname[1], timezone, daylight);

        return 0;
}

Outputs the following:

    tzname: (ART,ARST)  timezone: 10800  daylight:1
    tzname: (ART,ART)  timezone: 10800  daylight:0

I think it should output the same tzname twice, but as shown fails to do so 
when using
Argentina/Buenos Aires timezone.

The timezone has the peculiarity that some years we have DST and some years we 
don't.
This year we don't. I don't know if it happens with other timezones.

If tzset() is called again after localtime() it does not change the
tzname anymore.

As an example of the consequences of this behaviour, this breaks applications 
that need
to know the names of the local time zone in order to parse them from an 
external source.


After reading 
http://www.opengroup.org/onlinepubs/9699919799/functions/tzset.html and
http://www.opengroup.org/onlinepubs/9699919799/functions/localtime.html, I 
think the
correct output would be:

    tzname: (ART,ARST)  timezone: 10800  daylight:1
    tzname: (ART,ARST)  timezone: 10800  daylight:1

because even though there is no DST to be applied currently, there is a name 
for the
alternative DST timezone, and at some point DST could be applied.

If there is anything else I can do to get this bug fixed, please let me
know.

Thanks a lot,
    Alberto

** Affects: eglibc (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: argentina dst localtime time timezone tzdata tzset

-- 
localtime() changes tzname
https://bugs.launchpad.net/bugs/513874
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to