This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Different (and wrong) timezones reported by both strftime(3) and date(1)
- From: Egor Tensin <egor dot tensin at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Sun, 2 Nov 2014 13:49:19 +0300
- Subject: Different (and wrong) timezones reported by both strftime(3) and date(1)
- Authentication-results: sourceware.org; auth=none
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