Add Date.fromTime function, based on PR #357
This commit is contained in:
parent
f636b7576f
commit
f5c612f13c
2 changed files with 6 additions and 1 deletions
|
@ -5,7 +5,7 @@ module Date where
|
||||||
issues with internationalization or locale formatting.
|
issues with internationalization or locale formatting.
|
||||||
|
|
||||||
# Conversions
|
# Conversions
|
||||||
@docs read, toTime
|
@docs read, toTime, fromTime
|
||||||
|
|
||||||
# Extractions
|
# Extractions
|
||||||
@docs year, month, Month, day, dayOfWeek, Day, hour, minute, second
|
@docs year, month, Month, day, dayOfWeek, Day, hour, minute, second
|
||||||
|
@ -36,6 +36,10 @@ read = Native.Date.read
|
||||||
toTime : Date -> Time
|
toTime : Date -> Time
|
||||||
toTime = Native.Date.toTime
|
toTime = Native.Date.toTime
|
||||||
|
|
||||||
|
{-| Take a UNIX time and convert it to a `Date` -}
|
||||||
|
fromTime : Time -> Date
|
||||||
|
fromTime = Native.Date.fromTime
|
||||||
|
|
||||||
{-| Extract the year of a given date. Given the date 23 June 1990 at 11:45AM
|
{-| Extract the year of a given date. Given the date 23 June 1990 at 11:45AM
|
||||||
this returns the integer `1990`. -}
|
this returns the integer `1990`. -}
|
||||||
year : Date -> Int
|
year : Date -> Int
|
||||||
|
|
|
@ -27,6 +27,7 @@ Elm.Native.Date.make = function(elm) {
|
||||||
minute : function(d) { return d.getMinutes(); },
|
minute : function(d) { return d.getMinutes(); },
|
||||||
second : function(d) { return d.getSeconds(); },
|
second : function(d) { return d.getSeconds(); },
|
||||||
toTime : function(d) { return d.getTime(); },
|
toTime : function(d) { return d.getTime(); },
|
||||||
|
fromTime: function(t) { return new window.Date(t); },
|
||||||
dayOfWeek : function(d) { return { ctor:dayTable[d.getDay()] }; }
|
dayOfWeek : function(d) { return { ctor:dayTable[d.getDay()] }; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue