v1.2.0.1-beta1
|
Date prototype extension methods
Public Member Functions | |
Date | clone () |
Date | addSeconds (seconds) |
Date | addMinutes (seconds) |
Date | addHours (seconds) |
Date | addDays (days) |
Date | addMonths (months) |
Date | addYears (years) |
Date | compareToDate (otherDate) |
string | format (format) |
string | toLocaleDateString (locale, format) |
string | toLocaleString (locale, format) |
string | toLocaleTimeString (locale, format) |
Static Public Member Functions | |
Date | fromLocaleDateString (locale, dateString, format) |
Date | fromLocaleString (locale, dateTimeString, format) |
Date | fromLocaleTimeString (locale, timeString, format) |
Date addSeconds | ( | seconds | ) |
Adds seconds
to current date and returns new Date object. seconds
can be negative to subtract from current time and can be in any integer value range.
Date addMinutes | ( | seconds | ) |
Adds minutes
to current date and returns new Date object. minutes
can be negative to subtract from current time and can be in any integer value range.
Date addHours | ( | seconds | ) |
Adds hours
to current date and returns new Date object. hours
can be negative to subtract from current time and can be in any integer value range.
Date addDays | ( | days | ) |
Adds days
to current date and returns new Date object. days
can be negative to subtract from current date and can be in any integer value range.
Date addMonths | ( | months | ) |
Adds months
to current date and returns new Date object. months
can be negative to subtract from current date and can be in any integer value range.
Date addYears | ( | years | ) |
Adds years
to current date and returns new Date object. years
can be negative to subtract from current date and can be in any integer value range.
Date compareToDate | ( | otherDate | ) |
Compares this Date to otherDate
based only on the year, month and day parts, ignoring time part. Returns -1 if otherDate
is earlier than this date, 0 if the dates match, and 1 if otherDate
is later than this date.
string format | ( | format | ) |
Formats this date according the specified .NET-style format
string.
This function emulates the .NET DateTime.ToString()
method.
For example:
See formatting string reference at https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings#table-of-format-specifiers
|
static |
Converts the date string dateString
to a Date
object using given locale
and format
.
locale | A Locale object, obtained with the global locale() method. |
dateString | The input string to parse |
format | A Locale format constant or string format specifier. |
If format
is not specified, Locale.LongFormat will be used.
If locale
is not specified, the default locale will be used.
The following example shows a datetime being parsed from a datetime string in a certain format using the default locale
|
static |
Converts the date string dateTimeString
to a Date
object using given locale
and format
.
locale | A Locale object, obtained with the global locale() method. |
dateTimeString | The input string to parse |
format | A Locale format constant or string format specifier. |
If format
is not specified, Locale.LongFormat will be used.
If locale
is not specified, the default locale will be used.
The following example shows a datetime being parsed from a datetime string in a certain format using the default locale
|
static |
Converts the date string timeString
to a Date object using given locale
and format
.
locale | A Locale object, obtained with the global locale() method. |
timeString | The input string to parse |
format | A Locale format constant or string format specifier. |
If format
is not specified, Locale.LongFormat will be used.
If locale
is not specified, the default locale will be used.
The following example shows a datetime being parsed from a datetime string in a certain format using the German locale:
string toLocaleDateString | ( | locale, | |
format | |||
) |
Converts the Date to a string containing the date suitable for the specified locale
in the specified format
.
locale | A Locale object, obtained with the global locale() method. |
format | A Locale format constant or string format specifier. |
If format
is not specified, Locale.LongFormat will be used.
If locale
is not specified, the default 'locale()` will be used.
The following example shows the current date formatted for the German locale:
string toLocaleString | ( | locale, | |
format | |||
) |
Converts the Date to a string containing the date and time suitable for the specified locale
in the specified format
.
locale | A Locale object, obtained with the global locale() method. |
format | A Locale format constant or string format specifier. |
If format
is not specified, Locale.LongFormat will be used. If locale
is not specified, the default 'locale()` will be used.
The following example shows the current date and time formatted for the German locale:
string toLocaleTimeString | ( | locale, | |
format | |||
) |
Converts the Date to a string containing the time suitable for the specified locale
in the specified format
.
locale | A Locale object, obtained with the global locale() method. |
format | A Locale format constant or string format specifier. |
If format
is not specified, Locale.LongFormat will be used. If locale
is not specified, the default locale will be used.
The following example shows the current date and time formatted for the German locale: