[Haskell-cafe] Parsing LocalTime from Unix seconds

Neil Mayhew neil_mayhew at users.sourceforge.net
Mon Sep 17 19:29:21 UTC 2018


On 2018-09-17 12:01 AM, Tobias Dammers wrote:
> … you can convert unix timestamps to some "local time without timezone 
> info" data structure (e.g. LocalTime); whether you assume UTC or any 
> timezone becomes relevant when you want to convert that data structure 
> into a data structure that does contain timezone info explicitly (like 
> ZonedTime) or implicitly (like UTCTime).

I don't think this is possible. If you want to measure seconds since 
1970-01-01 00:00:00 local time (which may actually be 1969 in UTC) you 
have to know the timezone at the start (ie in 1970) and at the end (ie 
after the seconds have elapsed). That requires knowing whether DST 
applies at either end, and whether the location was rezoned during the 
intervening time. This requires IO and the conversion from seconds is no 
longer a pure operation.

IHMO, the only sane way to interpret seconds-since-the-epoch is using UTC.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180917/fdedab33/attachment.html>


More information about the Haskell-Cafe mailing list