DateTime class: Difference between revisions
From Catglobe Wiki
More actions
No edit summary |
No edit summary |
||
| Line 9: | Line 9: | ||
{{CGscriptConstructors_Template|Parameters= | {{CGscriptConstructors_Template|Parameters= | ||
{{CGscriptParameters_Template|Type=array|Name=<nowiki>value</nowiki>|Description=<nowiki>Value to parse as a date</nowiki>}} | {{CGscriptParameters_Template|Type=array|Name=<nowiki>value</nowiki>|Description=<nowiki>Value to parse as a date</nowiki>}} | ||
|Description=<nowiki>New based on a array representation of a date</nowiki>}} | |||
{{CGscriptConstructors_Template|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>value</nowiki>|Description=<nowiki>Value to parse as a date</nowiki>}} | |||
|Description=<nowiki>New based on a array representation of a date</nowiki>}} | |Description=<nowiki>New based on a array representation of a date</nowiki>}} | ||
{{CGscriptConstructors_Template|Parameters= | {{CGscriptConstructors_Template|Parameters= | ||
| Line 107: | Line 110: | ||
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>dayOfWeek</nowiki>|HasGetter=1|Description=<nowiki>Return day of week (0=Sunday, 1=Monday, ..., 6=Saturday)</nowiki>}} | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>dayOfWeek</nowiki>|HasGetter=1|Description=<nowiki>Return day of week (0=Sunday, 1=Monday, ..., 6=Saturday)</nowiki>}} | ||
|StaticMethods= | |StaticMethods= | ||
{{CGscriptMethods_Template|ReturnType= | {{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_addDays</nowiki>|Parameters= | ||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to operate on</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Day</nowiki>|Description=<nowiki>The number of days to add</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Add days to a DateTime object</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_addHours</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to operate on</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Hour</nowiki>|Description=<nowiki>The number of hours to add</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Add hours to a DateTime object</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_addMinutes</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to operate on</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Minute</nowiki>|Description=<nowiki>The number of minutes to add</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Add minutes to a DateTime object</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_addMonths</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to operate on</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Month</nowiki>|Description=<nowiki>The number of months to add</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Add months to a DateTime object</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_addSeconds</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to operate on</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Second</nowiki>|Description=<nowiki>The number of seconds to add</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Add seconds to a DateTime object</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_addYears</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to operate on</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Year</nowiki>|Description=<nowiki>The number of years to add</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Add years to a DateTime object</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>DateTime_compare</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>Be compared DateTime</nowiki>|Description=<nowiki>The DateTime to compare</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>To compare DateTime</nowiki>|Description=<nowiki>The DateTime to compare against</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Compare two DateTime objects. Returns -1 (less), 0 (equal), or 1 (greater)</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>DateTime_dayOfWeek</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to operate on</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Return day of week for a DateTime object</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>DateTime_daysBetween</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>First DateTime</nowiki>|Description=<nowiki>The first DateTime object</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>Second DateTime</nowiki>|Description=<nowiki>The second DateTime object</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Returns the number of whole days between two DateTime objects</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>DateTime_daysBetween</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>First DateTime</nowiki>|Description=<nowiki>The first DateTime object</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>Second DateTime</nowiki>|Description=<nowiki>The second DateTime object</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int?|Name=<nowiki>Timezone</nowiki>|Description=<nowiki>Unused</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Returns the number of whole days between two DateTime objects</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_fromInvariant</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=string|Name=<nowiki>DateTime string</nowiki>|Description=<nowiki>The invariant datetime string to parse</nowiki>}} | {{CGscriptParameters_Template|Type=string|Name=<nowiki>DateTime string</nowiki>|Description=<nowiki>The invariant datetime string to parse</nowiki>}} | ||
|Description=<nowiki>Parses an invariant datetime string to a DateTime object, or Empty when the input is absent</nowiki>}} | |Description=<nowiki>Parses an invariant datetime string to a DateTime object, or Empty when the input is absent</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType= | {{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_fromInvariant</nowiki>|Parameters= | ||
{{CGscriptParameters_Template|Type=string|Name=<nowiki>DateTime string</nowiki>|Description=<nowiki>The invariant datetime string to parse; pass empty together with the second argument to get min/max date</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool?|Name=<nowiki>if true and empty return maxdate or mindate</nowiki>|Description=<nowiki>When the string is empty: true returns MaxValue, false returns MinValue</nowiki>}} | {{CGscriptParameters_Template|Type=string|Name=<nowiki>DateTime string</nowiki>|Description=<nowiki>The invariant datetime string to parse; pass empty together with the second argument to get min/max date</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool?|Name=<nowiki>if true and empty return maxdate or mindate</nowiki>|Description=<nowiki>When the string is empty: true returns MaxValue, false returns MinValue</nowiki>}} | ||
|Description=<nowiki>Parses an invariant datetime string to a DateTime object, or Empty when both inputs are absent</nowiki>}} | |Description=<nowiki>Parses an invariant datetime string to a DateTime object (in the current user's timezone), or Empty when both inputs are absent</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType= | {{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_fromJson</nowiki>|Parameters= | ||
{{CGscriptParameters_Template|Type=string|Name=<nowiki>DateTime string</nowiki>|Description=<nowiki>The JSON datetime string to parse</nowiki>}} | {{CGscriptParameters_Template|Type=string|Name=<nowiki>DateTime string</nowiki>|Description=<nowiki>The JSON datetime string to parse</nowiki>}} | ||
|Description=<nowiki>Deserialises a JSON datetime string to a DateTime array, or Empty when the input is absent</nowiki>}} | |Description=<nowiki>Deserialises a JSON datetime string to a DateTime array, or Empty when the input is absent</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType= | {{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_fromJson</nowiki>|Parameters= | ||
{{CGscriptParameters_Template|Type=string|Name=<nowiki>DateTime string</nowiki>|Description=<nowiki>The JSON datetime string to parse; pass empty together with the second argument to get min/max date</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool?|Name=<nowiki>if true and empty return maxdate or mindate</nowiki>|Description=<nowiki>When the string is empty: true returns MaxValue, false returns MinValue</nowiki>}} | {{CGscriptParameters_Template|Type=string|Name=<nowiki>DateTime string</nowiki>|Description=<nowiki>The JSON datetime string to parse; pass empty together with the second argument to get min/max date</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool?|Name=<nowiki>if true and empty return maxdate or mindate</nowiki>|Description=<nowiki>When the string is empty: true returns MaxValue, false returns MinValue</nowiki>}} | ||
|Description=<nowiki>Deserialises a JSON datetime string to a DateTime array, or Empty when both inputs are absent</nowiki>}} | |Description=<nowiki>Deserialises a JSON datetime string to a DateTime array, or Empty when both inputs are absent</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>DateTime_getLastDateOfMonth</nowiki>|Parameters= | {{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_getByYMD</nowiki>|Parameters= | ||
{{CGscriptParameters_Template|Type=int|Name=<nowiki>Year</nowiki>|Description=<nowiki>Year</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Month</nowiki>|Description=<nowiki>Month</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Day</nowiki>|Description=<nowiki>Day</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Creates a DateTime array object from year, month and day</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_getByYMD</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=int|Name=<nowiki>Year</nowiki>|Description=<nowiki>Year</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Month</nowiki>|Description=<nowiki>Month</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Day</nowiki>|Description=<nowiki>Day</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Timezone</nowiki>|Description=<nowiki>Timezone ID</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Creates a DateTime array object from year, month, day and timezone</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_getByYMD</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=int|Name=<nowiki>Year</nowiki>|Description=<nowiki>Year</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Month</nowiki>|Description=<nowiki>Month</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Day</nowiki>|Description=<nowiki>Day</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Hour</nowiki>|Description=<nowiki>Hour</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Minute</nowiki>|Description=<nowiki>Minute</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Second</nowiki>|Description=<nowiki>Second</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Creates a DateTime array object from year, month, day, hour, minute and second</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_getByYMD</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=int|Name=<nowiki>Year</nowiki>|Description=<nowiki>Year</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Month</nowiki>|Description=<nowiki>Month</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Day</nowiki>|Description=<nowiki>Day</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Hour</nowiki>|Description=<nowiki>Hour</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Minute</nowiki>|Description=<nowiki>Minute</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Second</nowiki>|Description=<nowiki>Second</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Timezone</nowiki>|Description=<nowiki>Timezone ID</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Creates a DateTime array object from year, month, day, hour, minute, second and timezone</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_getLastDateOfMonth</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=int|Name=<nowiki>Year</nowiki>|Description=<nowiki>The year (e.g. 2024)</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Month</nowiki>|Description=<nowiki>The month number (1-12)</nowiki>}} | {{CGscriptParameters_Template|Type=int|Name=<nowiki>Year</nowiki>|Description=<nowiki>The year (e.g. 2024)</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Month</nowiki>|Description=<nowiki>The month number (1-12)</nowiki>}} | ||
|Description=<nowiki>Get the last date of the specified month</nowiki>}} | |Description=<nowiki>Get the last date of the specified month</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType= | {{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_getWeekEnd</nowiki>|Parameters= | ||
{{CGscriptParameters_Template|Type=int|Name=<nowiki>Year</nowiki>|Description=<nowiki>The year (e.g. 2024)</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Week</nowiki>|Description=<nowiki>The week number (1-53)</nowiki>}} | {{CGscriptParameters_Template|Type=int|Name=<nowiki>Year</nowiki>|Description=<nowiki>The year (e.g. 2024)</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Week</nowiki>|Description=<nowiki>The week number (1-53)</nowiki>}} | ||
|Description=<nowiki>Get the end day of the specified week and year</nowiki>}} | |Description=<nowiki>Get the end day of the specified week and year</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType= | {{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_getWeekStart</nowiki>|Parameters= | ||
{{CGscriptParameters_Template|Type=int|Name=<nowiki>Year</nowiki>|Description=<nowiki>The year (e.g. 2024)</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Week</nowiki>|Description=<nowiki>The week number (1-53)</nowiki>}} | {{CGscriptParameters_Template|Type=int|Name=<nowiki>Year</nowiki>|Description=<nowiki>The year (e.g. 2024)</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Week</nowiki>|Description=<nowiki>The week number (1-53)</nowiki>}} | ||
|Description=<nowiki>Get the start day of the specified week and year</nowiki>}} | |Description=<nowiki>Get the start day of the specified week and year</nowiki>}} | ||
| Line 131: | Line 190: | ||
{{CGscriptParameters_Template|Type=int|Name=<nowiki>Year</nowiki>|Description=<nowiki>The year (e.g. 2024)</nowiki>}} | {{CGscriptParameters_Template|Type=int|Name=<nowiki>Year</nowiki>|Description=<nowiki>The year (e.g. 2024)</nowiki>}} | ||
|Description=<nowiki>Determine whether the specified year is a leap year</nowiki>}} | |Description=<nowiki>Determine whether the specified year is a leap year</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType= | {{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>DateTime_objToInvariant</nowiki>|Parameters= | ||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to convert; pass empty to get an Empty result</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Converts a DateTime object to an invariant-format string, or Empty if the input is empty</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_parse</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=string|Name=<nowiki>DateTime string</nowiki>|Description=<nowiki>The string to parse as a DateTime</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>DateTime format string</nowiki>|Description=<nowiki>The format string</nowiki>}} | {{CGscriptParameters_Template|Type=string|Name=<nowiki>DateTime string</nowiki>|Description=<nowiki>The string to parse as a DateTime</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>DateTime format string</nowiki>|Description=<nowiki>The format string</nowiki>}} | ||
|Description=<nowiki>Parse a DateTime string to a DateTime object with the specified format</nowiki>}} | |Description=<nowiki>Parse a DateTime string to a DateTime object with the specified format</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType=number|Name=<nowiki>DateTime_secondsBetween</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>First DateTime</nowiki>|Description=<nowiki>The first DateTime object</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>Second DateTime</nowiki>|Description=<nowiki>The second DateTime object</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Returns the total number of seconds between two DateTime objects</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=number|Name=<nowiki>DateTime_secondsBetween</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>First DateTime</nowiki>|Description=<nowiki>The first DateTime object</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>Second DateTime</nowiki>|Description=<nowiki>The second DateTime object</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int?|Name=<nowiki>Timezone</nowiki>|Description=<nowiki>Unused</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Returns the total number of seconds between two DateTime objects</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_subtractDays</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to operate on</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Day</nowiki>|Description=<nowiki>The number of days to subtract</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Subtract days from a DateTime object</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_subtractHours</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to operate on</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Hour</nowiki>|Description=<nowiki>The number of hours to subtract</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Subtract hours from a DateTime object</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_subtractMinutes</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to operate on</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Minute</nowiki>|Description=<nowiki>The number of minutes to subtract</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Subtract minutes from a DateTime object</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_subtractMonths</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to operate on</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Month</nowiki>|Description=<nowiki>The number of months to subtract</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Subtract months from a DateTime object</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_subtractSeconds</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to operate on</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Second</nowiki>|Description=<nowiki>The number of seconds to subtract</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Subtract seconds from a DateTime object</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>DateTime_subtractYears</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to operate on</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>Year</nowiki>|Description=<nowiki>The number of years to subtract</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Subtract years from a DateTime object</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>DateTime_toInvariant</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to convert; pass empty to get an Empty result</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Converts a DateTime array object to an invariant-format string, or Empty if the input is empty</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>DateTime_toJson</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to serialise; pass empty to get an Empty result</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Serialises a DateTime to a JSON ISO 8601 string</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>DateTime_toJson</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>DateTime</nowiki>|Description=<nowiki>The DateTime object to serialise; pass empty to get an Empty result</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int?|Name=<nowiki>Type</nowiki>|Description=<nowiki>Output format: 0 = DateTime (default), 1 = DateOnly, 2 = TimeOnly</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Serialises a DateTime to a JSON ISO 8601 string (0=DateTime, 1=DateOnly, 2=TimeOnly)</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>DateTime_workDaysBetween</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>First DateTime</nowiki>|Description=<nowiki>The first DateTime object</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>Second DateTime</nowiki>|Description=<nowiki>The second DateTime object</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Returns the number of working days (excluding weekends) between two DateTime objects</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>DateTime_workDaysBetween</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>First DateTime</nowiki>|Description=<nowiki>The first DateTime object</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>Second DateTime</nowiki>|Description=<nowiki>The second DateTime object</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>Holiday</nowiki>|Description=<nowiki>List of holiday DateTime objects</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Returns the number of working days (excluding weekends and specified holidays) between two DateTime objects</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>DateTime_workDaysBetween</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>First DateTime</nowiki>|Description=<nowiki>The first DateTime object</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>Second DateTime</nowiki>|Description=<nowiki>The second DateTime object</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int?|Name=<nowiki>Timezone</nowiki>|Description=<nowiki>Unused</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Returns the number of working days (excluding weekends) between two DateTime objects with optional timezone override</nowiki>}} | |||
{{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>DateTime_workDaysBetween</nowiki>|Parameters= | |||
{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>First DateTime</nowiki>|Description=<nowiki>The first DateTime object</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=DateTime|Name=<nowiki>Second DateTime</nowiki>|Description=<nowiki>The second DateTime object</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>Holiday</nowiki>|Description=<nowiki>List of holiday DateTime objects</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int?|Name=<nowiki>Timezone</nowiki>|Description=<nowiki>Unused</nowiki>}} | |||
|Obsolete=1 | |||
|Description=<nowiki>Returns the number of working days (excluding weekends and specified holidays) between two DateTime objects with optional timezone override</nowiki>}} | |||
}} | }} | ||
Latest revision as of 03:52, 24 July 2026
DateTime
The object behind the first class construct: `DateTime d = #2024-01-01#;`.
Parent class
Inherits from Array
Constructors
- () - Now in UTC timezone
- (string value "Value to parse as a date, syntax is same as for constant values") - New based on a string representation of a date
- (array value "Value to parse as a date") - New based on a array representation of a date
- (DateTime value "Value to parse as a date") - New based on a array representation of a date
- (int Year "Year", int Month "Month", int Day "Day") - New based on year, month and day (current user's timezone)
- (int Year "Year", int Month "Month", int Day "Day", int Timezone "Timezone ID") - New based on year, month, day and timezone
- (int Year "Year", int Month "Month", int Day "Day", int Hour "Hour", int Minute "Minute", int Second "Second") - New based on year, month, day, hour, minute and second (current user's timezone)
- (int Year "Year", int Month "Month", int Day "Day", int Hour "Hour", int Minute "Minute", int Second "Second", int Timezone "Timezone ID") - New based on year, month, day, hour, minute, second and timezone
Methods
- number AsUnixtimeMillisecondsSince1970() - Return value as number of milliseconds since 1 / 1 1970
- number AsUnixtimeSecondsSince1970() - Return value as number of seconds since 1/1 1970
- int CompareTo(DateTime value "Value to compare to") - Compare to object. See ArrayConstant.OrderBy
- string ToString() - The string representation of the object.
- DateTime addDays(int Amount "Number of days to add") - Add days to this DateTime
- DateTime addHours(int Amount "Number of hours to add") - Add hours to this DateTime
- DateTime addMinutes(int Amount "Number of minutes to add") - Add minutes to this DateTime
- DateTime addMonths(int Amount "Number of months to add") - Add months to this DateTime
- DateTime addSeconds(int Amount "Number of seconds to add") - Add seconds to this DateTime
- DateTime addYears(int Amount "Number of years to add") - Add years to this DateTime
- int daysBetween(DateTime Second "The second DateTime object") - Returns the number of whole days between this and another DateTime
- object this[] { get; }(int index "Index") - Backward-compatible indexer
- number secondsBetween(DateTime Second "The second DateTime object") - Returns the total number of seconds between this and another DateTime
- Empty this[] { get; }(int index "Index", object value "Value to set") - Backward-compatible indexer
- DateTime subtractDays(int Amount "Number of days to subtract") - Subtract days from this DateTime
- DateTime subtractHours(int Amount "Number of hours to subtract") - Subtract hours from this DateTime
- DateTime subtractMinutes(int Amount "Number of minutes to subtract") - Subtract minutes from this DateTime
- DateTime subtractMonths(int Amount "Number of months to subtract") - Subtract months from this DateTime
- DateTime subtractSeconds(int Amount "Number of seconds to subtract") - Subtract seconds from this DateTime
- DateTime subtractYears(int Amount "Number of years to subtract") - Subtract years from this DateTime
- string toInvariant() - Converts this DateTime to an invariant-format string (yyyy-MM-dd HH:mm:ss)
- string toJson(int Type "Output format: 0=DateTime (default), 1=DateOnly, 2=TimeOnly") - Serialises to a JSON ISO 8601 string (0=DateTime, 1=DateOnly, 2=TimeOnly)
- int workDaysBetween(DateTime Second "The second DateTime object") - Returns the number of working days between this and another DateTime
- int workDaysBetween(DateTime Second "The second DateTime object", array Holidays "List of holiday DateTime objects") - Returns the number of working days (excluding holidays) between this and another DateTime
Properties
- array AsArray { get; } - Return value as the array representation of a date
- number Average { get; } - Average of the objects in the Array object. Can only use if all the elements are of type Number
- int Day { get; } - The day-of-month component (1–31)
- int Hour { get; } - The hour component (0–23)
- int IsoWeek { get; } - The ISO 8601 week number (1–53)
- int IsoWeekYear { get; } - The ISO 8601 week-year (may differ from Year for dates near year boundaries)
- number Max { get; } - Largest of all the objects in the Array object. Can only use if all the elements are of type Number
- int Millisecond { get; } - The millisecond component (0–999)
- number Min { get; } - Smallest of all the objects in the Array object. Can only use if all the elements are of type Number
- int Minute { get; } - The minute component (0–59)
- int Month { get; } - The month component (1–12)
- string ObjectTypeName { get; } - The name of the type of object.
- int Second { get; } - The second component (0–59)
- number Sum { get; } - Sum of all the objects in the Array object. Can only use if all the elements are of type Number
- TypeInformation TypeInformation { get; } - Get information about this class.
- int Year { get; } - The year component
- int dayOfWeek { get; } - Return day of week (0=Sunday, 1=Monday, ..., 6=Saturday)
Static Methods
- DateTime DateTime_addDays(DateTime DateTime "The DateTime object to operate on", int Day "The number of days to add") - Add days to a DateTime object
- DateTime DateTime_addHours(DateTime DateTime "The DateTime object to operate on", int Hour "The number of hours to add") - Add hours to a DateTime object
- DateTime DateTime_addMinutes(DateTime DateTime "The DateTime object to operate on", int Minute "The number of minutes to add") - Add minutes to a DateTime object
- DateTime DateTime_addMonths(DateTime DateTime "The DateTime object to operate on", int Month "The number of months to add") - Add months to a DateTime object
- DateTime DateTime_addSeconds(DateTime DateTime "The DateTime object to operate on", int Second "The number of seconds to add") - Add seconds to a DateTime object
- DateTime DateTime_addYears(DateTime DateTime "The DateTime object to operate on", int Year "The number of years to add") - Add years to a DateTime object
- int DateTime_compare(DateTime Be compared DateTime "The DateTime to compare", DateTime To compare DateTime "The DateTime to compare against") - Compare two DateTime objects. Returns -1 (less), 0 (equal), or 1 (greater)
- int DateTime_dayOfWeek(DateTime DateTime "The DateTime object to operate on") - Return day of week for a DateTime object
- int DateTime_daysBetween(DateTime First DateTime "The first DateTime object", DateTime Second DateTime "The second DateTime object") - Returns the number of whole days between two DateTime objects
- int DateTime_daysBetween(DateTime First DateTime "The first DateTime object", DateTime Second DateTime "The second DateTime object", int? Timezone "Unused") - Returns the number of whole days between two DateTime objects
- DateTime DateTime_fromInvariant(string DateTime string "The invariant datetime string to parse") - Parses an invariant datetime string to a DateTime object, or Empty when the input is absent
- DateTime DateTime_fromInvariant(string DateTime string "The invariant datetime string to parse; pass empty together with the second argument to get min/max date", bool? if true and empty return maxdate or mindate "When the string is empty: true returns MaxValue, false returns MinValue") - Parses an invariant datetime string to a DateTime object (in the current user's timezone), or Empty when both inputs are absent
- DateTime DateTime_fromJson(string DateTime string "The JSON datetime string to parse") - Deserialises a JSON datetime string to a DateTime array, or Empty when the input is absent
- DateTime DateTime_fromJson(string DateTime string "The JSON datetime string to parse; pass empty together with the second argument to get min/max date", bool? if true and empty return maxdate or mindate "When the string is empty: true returns MaxValue, false returns MinValue") - Deserialises a JSON datetime string to a DateTime array, or Empty when both inputs are absent
- DateTime DateTime_getByYMD(int Year "Year", int Month "Month", int Day "Day") - Creates a DateTime array object from year, month and day
- DateTime DateTime_getByYMD(int Year "Year", int Month "Month", int Day "Day", int Timezone "Timezone ID") - Creates a DateTime array object from year, month, day and timezone
- DateTime DateTime_getByYMD(int Year "Year", int Month "Month", int Day "Day", int Hour "Hour", int Minute "Minute", int Second "Second") - Creates a DateTime array object from year, month, day, hour, minute and second
- DateTime DateTime_getByYMD(int Year "Year", int Month "Month", int Day "Day", int Hour "Hour", int Minute "Minute", int Second "Second", int Timezone "Timezone ID") - Creates a DateTime array object from year, month, day, hour, minute, second and timezone
- DateTime DateTime_getLastDateOfMonth(int Year "The year (e.g. 2024)", int Month "The month number (1-12)") - Get the last date of the specified month
- DateTime DateTime_getWeekEnd(int Year "The year (e.g. 2024)", int Week "The week number (1-53)") - Get the end day of the specified week and year
- DateTime DateTime_getWeekStart(int Year "The year (e.g. 2024)", int Week "The week number (1-53)") - Get the start day of the specified week and year
- bool DateTime_isLeapYear(int Year "The year (e.g. 2024)") - Determine whether the specified year is a leap year
- string DateTime_objToInvariant(DateTime DateTime "The DateTime object to convert; pass empty to get an Empty result") - Converts a DateTime object to an invariant-format string, or Empty if the input is empty
- DateTime DateTime_parse(string DateTime string "The string to parse as a DateTime", string DateTime format string "The format string") - Parse a DateTime string to a DateTime object with the specified format
- number DateTime_secondsBetween(DateTime First DateTime "The first DateTime object", DateTime Second DateTime "The second DateTime object") - Returns the total number of seconds between two DateTime objects
- number DateTime_secondsBetween(DateTime First DateTime "The first DateTime object", DateTime Second DateTime "The second DateTime object", int? Timezone "Unused") - Returns the total number of seconds between two DateTime objects
- DateTime DateTime_subtractDays(DateTime DateTime "The DateTime object to operate on", int Day "The number of days to subtract") - Subtract days from a DateTime object
- DateTime DateTime_subtractHours(DateTime DateTime "The DateTime object to operate on", int Hour "The number of hours to subtract") - Subtract hours from a DateTime object
- DateTime DateTime_subtractMinutes(DateTime DateTime "The DateTime object to operate on", int Minute "The number of minutes to subtract") - Subtract minutes from a DateTime object
- DateTime DateTime_subtractMonths(DateTime DateTime "The DateTime object to operate on", int Month "The number of months to subtract") - Subtract months from a DateTime object
- DateTime DateTime_subtractSeconds(DateTime DateTime "The DateTime object to operate on", int Second "The number of seconds to subtract") - Subtract seconds from a DateTime object
- DateTime DateTime_subtractYears(DateTime DateTime "The DateTime object to operate on", int Year "The number of years to subtract") - Subtract years from a DateTime object
- string DateTime_toInvariant(DateTime DateTime "The DateTime object to convert; pass empty to get an Empty result") - Converts a DateTime array object to an invariant-format string, or Empty if the input is empty
- string DateTime_toJson(DateTime DateTime "The DateTime object to serialise; pass empty to get an Empty result") - Serialises a DateTime to a JSON ISO 8601 string
- string DateTime_toJson(DateTime DateTime "The DateTime object to serialise; pass empty to get an Empty result", int? Type "Output format: 0 = DateTime (default), 1 = DateOnly, 2 = TimeOnly") - Serialises a DateTime to a JSON ISO 8601 string (0=DateTime, 1=DateOnly, 2=TimeOnly)
- int DateTime_workDaysBetween(DateTime First DateTime "The first DateTime object", DateTime Second DateTime "The second DateTime object") - Returns the number of working days (excluding weekends) between two DateTime objects
- int DateTime_workDaysBetween(DateTime First DateTime "The first DateTime object", DateTime Second DateTime "The second DateTime object", array Holiday "List of holiday DateTime objects") - Returns the number of working days (excluding weekends and specified holidays) between two DateTime objects
- int DateTime_workDaysBetween(DateTime First DateTime "The first DateTime object", DateTime Second DateTime "The second DateTime object", int? Timezone "Unused") - Returns the number of working days (excluding weekends) between two DateTime objects with optional timezone override
- int DateTime_workDaysBetween(DateTime First DateTime "The first DateTime object", DateTime Second DateTime "The second DateTime object", array Holiday "List of holiday DateTime objects", int? Timezone "Unused") - Returns the number of working days (excluding weekends and specified holidays) between two DateTime objects with optional timezone override
Examples
//*Ex1
DateTime dt = new DateTime ();
print(dt.AsArray);//{2017,10,2,4,13,34,583,40,0}
//*Ex2
DateTime dt = new DateTime("2009/4/5");
print(dt.ToString());//2009-04-05 00:00:00
print(dt.AsArray);//{2009,4,5,0,0,0,0,14,0}
//*Ex3
DateTime dt = new DateTime({2017,10,2,4,13,34,583,40,0});
print(dt.ToString());//2017-10-02 04:13:34
print(dt.AsUnixtimeMillisecondsSince1970());//1506917614583
print(dt.AsUnixtimeSecondsSince1970());//1506917614