Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Apr 2002 11:57:38 -0700
From:      Sean Chittenden <sean@chittenden.org>
To:        Garrett Wollman <wollman@lcs.mit.edu>
Cc:        freebsd-standards@FreeBSD.ORG
Subject:   Re: mktime() doesn't fix deadzones...
Message-ID:  <20020412115738.F73286@ninja1.internal>
In-Reply-To: <200204102028.g3AKS5h68482@khavrinen.lcs.mit.edu>; from "wollman@lcs.mit.edu" on Wed, Apr 10, 2002 at = 04:28:05PM
References:  <sean@chittenden.org> <200204101233.g3ACXaOF052655@hak.lan.Awfulhak.org> <20020410125409.B34587@ninja1.internal> <200204102028.g3AKS5h68482@khavrinen.lcs.mit.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
> > I like that mktime() returns -1 for invalid times, but I don't
> > think Apr 7th @2am-8 is an invalid time.  Not correct, but not
> > invalid either.
> 
> There is no such time as 2001-04-07T0200 when US DST rules are used.
> This time simply does not exist, and mktime() correctly returns an
> error.  It has no way of knowing that you ``really meant''
> 2001-04-07T0300.

There is no February 29th most years, but if you put in Feb 29, it'll
automatically figure out that you wanted March 1st.

> > Sun Apr 07 02:00:00 PST 2002 =3D 1018173600
> 
> ...except that PST is not in effect at that time in your timezone.

I'm not one to disagree, but when I get handed bogus data, it strikes
me as very possible for mktime() to normalize the dates/times.  Seems
a tad wasteful and unnecessary to have programmers deal with this.  I
don't particularly want a lecture on timezones from mktime(), I just
want it to parse, apply structural rules, normalize the time, and
return time_t.  If I get time_t, then it's right.  I don't really care
if my timezone offset is -48hrs or if I put in 36hrs in a day, I want
time_t back.

Is there another syscall that doesn't validate the data, but returns
time_t?  Something that more closely conformed with other OSes would
be nice for code portability.  Have you tried running your code
fragment on Sun, Linux, or DEC?

-sc

-- 
Sean Chittenden

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-standards" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020412115738.F73286>