public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* strftime trouble with %z
@ 2011-04-14 14:20 Peter Rosin
  2011-04-18 19:33 ` Corinna Vinschen
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Rosin @ 2011-04-14 14:20 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-04-18 19:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-14 14:20 strftime trouble with %z Peter Rosin
2011-04-18 19:33 ` Corinna Vinschen
2011-04-18 20:03   ` Peter Rosin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).