From: Peter Rosin <peda@lysator.liu.se>
To: cygwin@cygwin.com
Subject: strftime trouble with %z
Date: Thu, 14 Apr 2011 14:20:00 -0000 [thread overview]
Message-ID: <4DA6B9BA.2020500@lysator.liu.se> (raw)
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
next reply other threads:[~2011-04-14 9:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-14 14:20 Peter Rosin [this message]
2011-04-18 19:33 ` Corinna Vinschen
2011-04-18 20:03 ` Peter Rosin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DA6B9BA.2020500@lysator.liu.se \
--to=peda@lysator.liu.se \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).