Data.JSDate
- Package
- purescript-js-date
- Repository
- purescript-contrib/purescript-js-date
A module providing a type and operations for the native JavaScript Date
object.
The JSDate
type and associated functions are provided for interop
purposes with JavaScript, but for working with dates in PureScript it is
recommended that DateTime
representation is used instead - DateTime
offers greater type safety, a more PureScript-friendly interface, and has
a Generic
instance.
#fromDateTime Source
fromDateTime :: DateTime -> JSDate
Converts a DateTime
value into a native JavaScript date object. The
resulting date value is guaranteed to be valid.
#toDateTime Source
toDateTime :: JSDate -> Maybe DateTime
Attempts to construct a DateTime
value for a JSDate
. Nothing
is
returned only when the date value is an invalid date.
#jsdateLocal Source
jsdateLocal :: forall eff. { day :: Number, hour :: Number, millisecond :: Number, minute :: Number, month :: Number, second :: Number, year :: Number } -> Eff (locale :: LOCALE | eff) JSDate
Constructs a new JSDate
from component values using the current machine's
locale. If any of the values are NaN
the resulting date will be invalid.
#parse Source
parse :: forall eff. String -> Eff (locale :: LOCALE | eff) JSDate
Attempts to parse a date from a string. The behaviour of this function is implementation specific until ES5, so may not always have the same behaviour for a given string. The RFC2822 and ISO8601 date string formats should parse consistently.
The LOCALE
effect is present here as if no time zone is specified in the
string the current locale's time zone will be used instead.
#getUTCDate Source
getUTCDate :: JSDate -> Number
Returns the day of the month for a date, according to UTC.
#getUTCFullYear Source
getUTCFullYear :: JSDate -> Number
Returns the year for a date, according to UTC.
#getUTCHours Source
getUTCHours :: JSDate -> Number
Returns the hours for a date, according to UTC.
#getUTCMilliseconds Source
getUTCMilliseconds :: JSDate -> Number
Returns the milliseconds for a date, according to UTC.
#getUTCMinutes Source
getUTCMinutes :: JSDate -> Number
Returns the minutes for a date, according to UTC.
#getUTCMonth Source
getUTCMonth :: JSDate -> Number
Returns the month for a date, according to UTC.
#getUTCSeconds Source
getUTCSeconds :: JSDate -> Number
Returns the seconds for a date, according to UTC.
#getFullYear Source
getFullYear :: forall eff. JSDate -> Eff (locale :: LOCALE | eff) Number
Returns the year for a date, according to the current machine's date/time locale.
#getMilliseconds Source
getMilliseconds :: forall eff. JSDate -> Eff (locale :: LOCALE | eff) Number
Returns the milliseconds for a date, according to the current machine's date/time locale.
#getMinutes Source
getMinutes :: forall eff. JSDate -> Eff (locale :: LOCALE | eff) Number
Returns the minutes for a date, according to the current machine's date/time locale.
#getSeconds Source
getSeconds :: forall eff. JSDate -> Eff (locale :: LOCALE | eff) Number
Returns the seconds for a date, according to the current machine's date/time locale.
#getTimezoneOffset Source
getTimezoneOffset :: forall eff. JSDate -> Eff (locale :: LOCALE | eff) Number
Returns the time-zone offset for a date, according to the current machine's date/time locale.
#toDateString Source
toDateString :: JSDate -> String
Returns the date portion of a date value as a human-readable string.
#toISOString Source
toISOString :: forall eff. JSDate -> Eff (err :: EXCEPTION | eff) String
Converts a date value to an ISO 8601 Extended format date string.
#toTimeString Source
toTimeString :: JSDate -> String
Returns the time portion of a date value as a human-readable string.
#toUTCString Source
toUTCString :: JSDate -> String
Returns the date as a string using the UTC timezone.
- Modules
- Data.
JSDate