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 -> JSDateConverts a DateTime value into a native JavaScript date object. The
resulting date value is guaranteed to be valid.
#toDateTime Source
toDateTime :: JSDate -> Maybe DateTimeAttempts to construct a DateTime value for a JSDate. Nothing is
returned only when the date value is an invalid date.
#fromInstant Source
fromInstant :: Instant -> JSDateCreates a JSDate from an Instant value.
#jsdateLocal Source
jsdateLocal :: { day :: Number, hour :: Number, millisecond :: Number, minute :: Number, month :: Number, second :: Number, year :: Number } -> Effect JSDateConstructs 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 :: String -> Effect JSDateAttempts to parse a date from a string. The behavior of this function is implementation specific until ES5, so may not always have the same behavior for a given string. For this reason, it is strongly encouraged that you avoid this function if at all possible.
If you must use it, the RFC2822 and ISO8601 date string formats should parse consistently.
This function is effectful because if no time zone is specified in the string the current locale's time zone will be used instead.
#getUTCDate Source
getUTCDate :: JSDate -> NumberReturns the day of the month for a date, according to UTC.
#getUTCFullYear Source
getUTCFullYear :: JSDate -> NumberReturns the year for a date, according to UTC.
#getUTCHours Source
getUTCHours :: JSDate -> NumberReturns the hours for a date, according to UTC.
#getUTCMilliseconds Source
getUTCMilliseconds :: JSDate -> NumberReturns the milliseconds for a date, according to UTC.
#getUTCMinutes Source
getUTCMinutes :: JSDate -> NumberReturns the minutes for a date, according to UTC.
#getUTCMonth Source
getUTCMonth :: JSDate -> NumberReturns the month for a date, according to UTC.
#getUTCSeconds Source
getUTCSeconds :: JSDate -> NumberReturns the seconds for a date, according to UTC.
#getFullYear Source
getFullYear :: JSDate -> Effect NumberReturns the year for a date, according to the current machine's date/time locale.
#getMilliseconds Source
getMilliseconds :: JSDate -> Effect NumberReturns the milliseconds for a date, according to the current machine's date/time locale.
#getMinutes Source
getMinutes :: JSDate -> Effect NumberReturns the minutes for a date, according to the current machine's date/time locale.
#getSeconds Source
getSeconds :: JSDate -> Effect NumberReturns the seconds for a date, according to the current machine's date/time locale.
#getTimezoneOffset Source
getTimezoneOffset :: JSDate -> Effect NumberReturns the time-zone offset for a date, according to the current machine's date/time locale.
#toDateString Source
toDateString :: JSDate -> StringReturns the date portion of a date value as a human-readable string.
#toISOString Source
toISOString :: JSDate -> Effect StringConverts a date value to an ISO 8601 Extended format date string.
#toTimeString Source
toTimeString :: JSDate -> StringReturns the time portion of a date value as a human-readable string.
#toUTCString Source
toUTCString :: JSDate -> StringReturns the date as a string using the UTC timezone.
- Modules
- Data.
JSDate