Skip to content

Instantly share code, notes, and snippets.

@Dremora
Last active October 8, 2016 19:02
Show Gist options
  • Save Dremora/448933957896609330c461b62e6538c4 to your computer and use it in GitHub Desktop.
Save Dremora/448933957896609330c461b62e6538c4 to your computer and use it in GitHub Desktop.
Types and functions for working with time
type Date
type Time
type Timestamp
type Timezone = System | UTC | TimezoneData ...
type IntervalUnit = Millisecond | Second | Minute | Hour | Day | Month | Year
type Interval
type Locale
type Format
date : Int -> Int -> Int -> Date
time : Int -> Int -> Int -> Time
fromDateTime : Date -> Time -> Timezone -> Timestamp
toUnixTimestamp : Timestamp -> Int
fromUnixTimestamp : Int -> Timestamp
parse : String -> Format -> Timezone -> Maybe Timestamp
parseWithTimezone : String -> Format -> Maybe (Timestamp, Timezone)
format : Locale -> Format -> Timezone -> Timestamp -> String
millisecond : Timezone -> Timestamp -> Int
second : Timezone -> Timestamp -> Int
minute : Timezone -> Timestamp -> Int
hour : Timezone -> Timestamp -> Int
day : Timezone -> Timestamp -> Int
month : Timezone -> Timestamp -> Int
year : Timezone -> Timestamp -> Int
dayOfWeek : Timezone -> Timestamp -> Int
-- or
get : Timezone -> IntervalUnit -> Timestamp -> Int
set : Timezone -> IntervalUnit -> Int -> Timestamp -> Timestamp
isAfter : Timestamp -> Timestamp -> Boolean
isBefore : Timestamp -> Timestamp -> Boolean
isSame : Timestamp -> Timestamp -> Boolean
interval : IntervalUnit -> Int -> Interval
add : Timezone -> Interval -> Timestamp -> Timestamp -- does it need Timezone?
subtract : Timezone -> Interval -> Timestamp -> Timestamp -- does it need Timezone?
startOf : Timezone -> IntervalUnit -> Timestamp -> Timestamp
endOf : Timezone -> IntervalUnit -> Timestamp -> Timestamp
isLeapYear : Int -> Boolean
isLeapSecond : Timestamp -> Boolean
isSummerTime : Timestamp -> Timezone -> Boolean
timezoneOffset : Timestamp -> Timezone -> Int
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment