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.
#fromInstant Source
fromInstant :: Instant -> JSDate
Creates a JSDate
from an Instant
value.
#jsdateLocal Source
jsdateLocal :: { day :: Number, hour :: Number, millisecond :: Number, minute :: Number, month :: Number, second :: Number, year :: Number } -> Effect 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 :: String -> Effect JSDate
Attempts 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 -> 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 :: JSDate -> Effect Number
Returns the year for a date, according to the current machine's date/time locale.
#getMilliseconds Source
getMilliseconds :: JSDate -> Effect Number
Returns the milliseconds for a date, according to the current machine's date/time locale.
#getMinutes Source
getMinutes :: JSDate -> Effect Number
Returns the minutes for a date, according to the current machine's date/time locale.
#getSeconds Source
getSeconds :: JSDate -> Effect Number
Returns the seconds for a date, according to the current machine's date/time locale.
#getTimezoneOffset Source
getTimezoneOffset :: JSDate -> Effect 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 :: JSDate -> Effect 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