time icon indicating copy to clipboard operation
time copied to clipboard

Time offsets

Open alexshadley opened this issue 6 years ago • 1 comments

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).

alexshadley avatar Apr 09 '19 23:04 alexshadley

I too would be interested in gauging the interest in this, as it's a feature of my upcoming SmartTime library (not ready yet).

Erudition avatar Jun 09 '19 17:06 Erudition