Different (and wrong) timezones reported by both strftime(3) and date(1)

Egor Tensin egor.tensin@gmail.com
Sun Nov 2 10:49:00 GMT 2014


Hello,

I've run into an issue of both strftime(3) and date(1) reporting
different (and wrong) timezones. I'm in the MSK timezone (switched
from +0400 to +0300 on 10/26/14). However, as of today, 11/2/14, the
following simple program

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

int main()
{
    char buf[128];
    time_t tt = time(NULL);
    tm* lt = localtime(&tt);
    strftime(&buf[0], 128, "%H:%M:%S%z\n", lt);
    printf("%s\n", buf);
    return 0;
}

outputs "14:10:00+0330". Both time and timezone here are wrong (it
should be "13:10:00+0300" instead, and Moscow is never in the "+0330"
timezone).

Running "date +'%H:%M:%S%z'" at the same time produces
"14:10:00+0400", which is better, since Moscow was in the "+0400"
timezone a week ago, but it still should be "13:10:00+0300" as in the
example above).

Curiously enough, `unset`ting the TZ environment variable fixes both
of these issues.

Anyway, I hope somebody will be able to fix this issue anytime.

Thanks,
Egor.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list