time
time copied to clipboard
Time offsets
It would be nice if there was some sort of API that could add some time unit to a Posix time, for instance to get the time 5 hours from some input Posix time. The advantage being that developers wouldn't need to convert Posix to milliseconds, add the time, and convert back to Posix. Additionally, developers wouldn't need to lookup the number of milliseconds in their desired time increment. I'm imagining something akin to
offsetSeconds : Int -> Posix -> Posix
offsetMinutes : Int -> Posix -> Posix
offsetHours : Int -> Posix -> Posix
offsetDays : Int -> Posix -> Posix
where int can be either positive or negative. Additionally, pipeline syntax could be used to produce combinations of time units, for instance:
addHourThirty : Posix -> Posix
addHourThirty t =
t
|> offsetHours 1
|> offsetMinutes 30
If this is indeed a feature the community is interested in, I'd be happy to develop it (shouldn't be too difficult).
I too would be interested in gauging the interest in this, as it's a feature of my upcoming SmartTime library (not ready yet).