Package index
server-reason-react
Library server-reason-react.js
Js
. Date
Module
Module Js.Date Source JavaScript Date implementation following ECMA-262 §21.4
This is a spec-compliant implementation using only OCaml stdlib + Unix. Internal representation: float (milliseconds since Unix epoch, or NaN for invalid dates).
The Date type - represents milliseconds since Unix epoch, or NaN for invalid dates
ConstructorsReturns a date representing the current time
Create a Date from epoch milliseconds
Create a Date by parsing a string
Source val makeWithYM : year :float -> month :float -> t Create a Date from year and month (local time). Note: Years 0-99 are treated as 1900-1999
Source val makeWithYMD : year :float -> month :float -> date :float -> t Create a Date from year, month, date (local time)
Source val makeWithYMDH : year :float -> month :float -> date :float -> hours :float -> t Create a Date from year, month, date, hours (local time)
Source val makeWithYMDHM :
year :float ->
month :float ->
date :float ->
hours :float ->
minutes :float ->
t Create a Date from year, month, date, hours, minutes (local time)
Source val makeWithYMDHMS :
year :float ->
month :float ->
date :float ->
hours :float ->
minutes :float ->
seconds :float ->
t Create a Date from all components (local time)
Date.UTC constructorsSource val utc :
year :float ->
month :float ->
?day :float ->
?hours :float ->
?minutes :float ->
?seconds :float ->
?ms :float ->
unit ->
floatDate.UTC(year, month, date[, hours[, minutes[, seconds[, ms]]]]) Returns epoch milliseconds for the given UTC date components. Note: Years 0-99 are treated as 1900-1999
Source val utcWithYM : year :float -> month :float -> floatDate.UTC with year and month only
Source val utcWithYMD : year :float -> month :float -> date :float -> floatDate.UTC with year, month, date
Source val utcWithYMDH :
year :float ->
month :float ->
date :float ->
hours :float ->
floatDate.UTC with year, month, date, hours
Source val utcWithYMDHM :
year :float ->
month :float ->
date :float ->
hours :float ->
minutes :float ->
floatDate.UTC with year, month, date, hours, minutes
Source val utcWithYMDHMS :
year :float ->
month :float ->
date :float ->
hours :float ->
minutes :float ->
seconds :float ->
floatDate.UTC with all components
Date.now and Date.parseDate.now() - returns current time as epoch milliseconds
Source val parse : string -> floatDate.parse(string) - parses a date string, returns NaN on failure. Supports ISO 8601 and legacy formats.
Source val parseAsFloat : string -> float UTC GettersReturns the primitive value (epoch ms), equivalent to getTime
Returns the epoch milliseconds
Returns the day of the month (1-31) in UTC
Returns the day of the week (0=Sunday, 6=Saturday) in UTC
Source val getUTCFullYear : t -> floatReturns the hours (0-23) in UTC
Source val getUTCMilliseconds : t -> floatReturns the milliseconds (0-999) in UTC
Source val getUTCMinutes : t -> floatReturns the minutes (0-59) in UTC
Returns the month (0-11) in UTC
Source val getUTCSeconds : t -> floatReturns the seconds (0-59) in UTC
Local Time GettersReturns the day of the month (1-31) in local time
Returns the day of the week (0=Sunday, 6=Saturday) in local time
Returns the year in local time
Returns the hours (0-23) in local time
Source val getMilliseconds : t -> floatReturns the milliseconds (0-999) in local time
Returns the minutes (0-59) in local time
Returns the month (0-11) in local time
Returns the seconds (0-59) in local time
Source val getTimezoneOffset : t -> floatReturns the timezone offset in minutes (positive = west of UTC)
UTC SettersAll setters return the new timestamp (milliseconds).
Source val setUTCDate : float -> t -> floatSource val setUTCFullYear : float -> t -> floatSource val setUTCFullYearM : year :float -> month :float -> t -> floatSource val setUTCFullYearMD : year :float -> month :float -> date :float -> t -> floatSource val setUTCHours : float -> t -> floatSource val setUTCHoursM : hours :float -> minutes :float -> t -> floatSource val setUTCHoursMS : hours :float -> minutes :float -> seconds :float -> t -> floatSource val setUTCHoursMSMs :
hours :float ->
minutes :float ->
seconds :float ->
milliseconds :float ->
t ->
floatSource val setUTCMilliseconds : float -> t -> floatSource val setUTCMinutes : float -> t -> floatSource val setUTCMinutesS : minutes :float -> seconds :float -> t -> floatSource val setUTCMinutesSMs :
minutes :float ->
seconds :float ->
milliseconds :float ->
t ->
floatSource val setUTCMonth : float -> t -> floatSource val setUTCMonthD : month :float -> date :float -> t -> floatSource val setUTCSeconds : float -> t -> floatSource val setUTCSecondsMs : seconds :float -> milliseconds :float -> t -> floatSource val setUTCTime : float -> t -> float Local Time SettersAll setters return the new timestamp (milliseconds).
Source val setDate : float -> t -> floatSource val setFullYear : float -> t -> floatSource val setFullYearM : year :float -> month :float -> t -> floatSource val setFullYearMD : year :float -> month :float -> date :float -> t -> floatSource val setHours : float -> t -> floatSource val setHoursM : hours :float -> minutes :float -> t -> floatSource val setHoursMS : hours :float -> minutes :float -> seconds :float -> t -> floatSource val setHoursMSMs :
hours :float ->
minutes :float ->
seconds :float ->
milliseconds :float ->
t ->
floatSource val setMilliseconds : float -> t -> floatSource val setMinutes : float -> t -> floatSource val setMinutesS : minutes :float -> seconds :float -> t -> floatSource val setMinutesSMs :
minutes :float ->
seconds :float ->
milliseconds :float ->
t ->
floatSource val setMonth : float -> t -> floatSource val setMonthD : month :float -> date :float -> t -> floatSource val setSeconds : float -> t -> floatSource val setSecondsMs : seconds :float -> milliseconds :float -> t -> floatSource val setTime : float -> t -> float String ConversionSource val toDateString : t -> stringReturns a human-readable date string (local time)
Source val toISOString : t -> stringReturns an ISO 8601 formatted string: "YYYY-MM-DDTHH:mm:ss.sssZ" Raises Invalid_argument for invalid dates
Source val toJSON : t -> string option Returns ISO string wrapped in option, None for invalid dates
Source val toJSONUnsafe : t -> stringSame as toISOString - throws for invalid dates
Source val toLocaleDateString : t -> stringReturns locale-formatted date string (simplified implementation)
Source val toLocaleString : t -> stringReturns locale-formatted string (simplified implementation)
Source val toLocaleTimeString : t -> stringReturns locale-formatted time string (simplified implementation)
Returns full string representation in local time
Source val toTimeString : t -> stringReturns time string in local time
Source val toUTCString : t -> stringReturns string in UTC: "Tue, 02 Dec 2025 09:30:00 GMT"