Skip to content

Time offsets #18

@alexshadley

Description

@alexshadley

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions