Subject: Re: mktime(3) fails to convert a time in the "spring forward gap"
To: <>
From: Ignatios Souvatzis <ignatios@theory.cs.uni-bonn.de>
List: tech-userlevel
Date: 10/17/2002 14:17:40
--+QahgC5+KEYLbs62
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Wed, Oct 09, 2002 at 04:02:35PM -0400, Andrew Brown wrote:
> >If you want an hour after a given time, isn't it better to get a time_t
> >and do the math on it?
>=20
> almost. suppose you wish to add a day. simply adding 86400 won't get
> the right answer either, because when you skip an hour due to daylight
> savings, a day is only 82800 seconds long.
Those are two different days.
If you want to skip a real day, just do the time_t arithmetic.
If you want to skip a _calendar_ day, you have a problem ---=20
There _is_ no calendar date corresponding to day foo, 02:30:00 + one calend=
ar
day, in some timezones, for some value of foo. You have to decide what you
really want to compute in this case (e.g., there are special train
schedules...) If you don't want to consider timezones with DST, just use the
first option.
Regards,
-is
--+QahgC5+KEYLbs62
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: 2.6.i
iQEVAgUBPa6qHjCn4om+4LhpAQGfmQgAhFEhojegExJND1Giu73wkwhueW5j4OdN
Mad4RV0irLnQpXgZDJ1XUf4kXgnOdwVrxa3IHaTK5YOPiHI9jdgjTFYBWJKWioCS
jXxr+FfX9bzaOl4N3O9FHc/iFUyZztDxFP+6hf7+21WWywxxPk0Q4Eon4PoGDry2
a7i0Xw2Qq7k1vsm5seQNVWUZM7uP+NKmJvBaSY0t3yPFlVB1zzz/YXK+2NWwrUSC
PG2Vllch6GKJg9TKptzF0zWNtAhtRgjRZ9BQlWoUheqrbZ1kIN1lnT3CXh0p4QLx
tdVkmSeHYSWT2cKdsZGaFryaJJQ8U1kxhsseM7gInanKHXACC3Br8w==
=+QhI
-----END PGP SIGNATURE-----
--+QahgC5+KEYLbs62--