tomjaguarpaw / tilapia

Improving all Haskell's programmer interfaces

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does it make any sense for LocalTime to interact with NominalDiffTime?

tomjaguarpaw opened this issue · comments

time has

-- addLocalTime a b = a + b
addLocalTime :: NominalDiffTime -> LocalTime -> LocalTime

-- diffLocalTime a b = a - b
diffLocalTime :: LocalTime -> LocalTime -> NominalDiffTime

But does that make any sense? You can't possibly know what LocalTime it is one hour from now because of daylight savings changes. time only makes sense of this by assuming the LocalTimes are in UTCTime, but if that's what the user wanted they would have converted to UTCTime themselves (or just used UTCTime in the first place).

Next action: determine whether I'm right and if so then try to persuade the maintainer to deprecate these functions. If these functions really are useful then they should probably be called addUTCLocalTime and diffUTCLocalTime, or something.

Related: haskell/time#169

Ah, but maybe this feature of LocalTime does make sense if we interpret it as "a reading on a clock that has no knowledge of time zones or any features more complicated than just displaying a time and date". See tomjaguarpaw/haskell-opaleye#495 (comment)

My second guess was right: haskell/time#169 (comment).

Next action: make a PR to document this.