This is the mail archive of the
cygwin
mailing list for the Cygwin project.
strftime trouble with %z
- From: Peter Rosin <peda at lysator dot liu dot se>
- To: cygwin at cygwin dot com
- Date: Thu, 14 Apr 2011 11:09:14 +0200
- Subject: strftime trouble with %z
Hi!
I'm getting somewhat troublesome output from the below STC.
It seems as if gmtime mucks with something, or that
localtime is not filling in everything it needs to?
------------------8<---(zone.c)---------
#include <stdio.h>
#include <time.h>
int main(void)
{
char zone[6];
struct tm *tm;
time_t now = time(NULL);
tm = localtime(&now);
strftime(zone, sizeof(zone), "%z", tm);
printf("%s %d %d\n", zone, timezone, tm->tm_isdst);
tm = localtime(&now);
strftime(zone, sizeof(zone), "%z", tm);
printf("%s %d %d\n", zone, timezone, tm->tm_isdst);
tm = gmtime(&now);
tm = localtime(&now);
strftime(zone, sizeof(zone), "%z", tm);
printf("%s %d %d\n", zone, timezone, tm->tm_isdst);
return 0;
}
------------------8<--------------------
I expect three equal lines, e.g.
+0200 -3600 1
+0200 -3600 1
+0200 -3600 1
but I get this on Cygwin:
+0200 -3600 1
+0200 -3600 1
+0000 -3600 1
$ cygcheck -c gcc4 cygwin
Cygwin Package Information
Package Version Status
cygwin 1.7.9-1 OK
gcc4 4.3.4-4 OK
FWIW, I have tested the STC on Linux and Solaris 10 and they
behave as I expected...
Cheers,
Peter
--
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