From owner-freebsd-stable Thu Oct 17 21:21:37 2002 Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 709EC37B401 for ; Thu, 17 Oct 2002 21:21:35 -0700 (PDT) Received: from mta6.snfc21.pbi.net (mta6.snfc21.pbi.net [206.13.28.240]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0986D43E6E for ; Thu, 17 Oct 2002 21:21:35 -0700 (PDT) (envelope-from mbsd@pacbell.net) Received: from atlas ([64.165.199.240]) by mta6.snfc21.pbi.net (iPlanet Messaging Server 5.1 (built May 7 2001)) with ESMTP id <0H4500MV6TFYAN@mta6.snfc21.pbi.net> for freebsd-stable@freebsd.org; Thu, 17 Oct 2002 21:21:34 -0700 (PDT) Date: Thu, 17 Oct 2002 21:21:34 -0700 (PDT) From: =?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= Subject: Re: mktime problem? In-reply-to: <3DAF7D3A.7060603@ntmk.ru> X-X-Sender: mikko@atlas.home To: Boris Kovalenko Cc: freebsd-stable@freebsd.org Message-id: <20021017211459.L308-100000@atlas.home> MIME-version: 1.0 Content-type: TEXT/PLAIN; charset=US-ASCII Content-transfer-encoding: 7BIT Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 18 Oct 2002, Boris Kovalenko wrote: > Hello! > > First the simple source code: > #include > #include > > 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