Date: Thu, 17 Oct 2002 21:21:34 -0700 (PDT) From: =?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= <mbsd@pacbell.net> To: Boris Kovalenko <boris@ntmk.ru> Cc: freebsd-stable@freebsd.org Subject: Re: mktime problem? Message-ID: <20021017211459.L308-100000@atlas.home> In-Reply-To: <3DAF7D3A.7060603@ntmk.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 18 Oct 2002, Boris Kovalenko wrote: > Hello! > > First the simple source code: > #include <stdio.h> > #include <sys/time.h> > > int main(int argc, char **argv) > { > time_t today = time( NULL ); > struct tm temp = *localtime( &today ); > > temp.tm_hour = 24; > temp.tm_min = 0; > temp.tm_sec = 0; > temp.tm_mday = 27; printf("is dst = %d\n", temp.tm_isdst); temp.tm_isdst = -1; > > today = mktime( &temp ); > printf("%s\n", ctime( &today )); > return 0; > } > > I expect 28 Oct 00:00, but got 27 Oct 23:00. Why? Daylight saving should > be at 28 Oct 02:00? My zoneinfo is Yekaterinburg. Seems to be intentional: % man mktime [...] "A positive or zero value for tm_isdst causes mktime() to presume initially that summer time (for example, Daylight Saving Time) is or is not in effect for the specified time, respectively. A negative value for tm_isdst causes the mktime() function to attempt to divine whether summer time is in effect for the specified time." Looks like a verbatim copy of the text in IEEE Std 1003.1-2001 (SUSv3). $.02, /Mikko To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021017211459.L308-100000>