new FlexDateTime(valueopt, monthopt, dayopt, hoursopt, minutesopt)
Constructs a FlexDateTime from the argument(s), which can be a Date object, another FlexDateTime, undefined, or component values. If undefined, all components of the returned FlexDateTime are undefined
Name | Type | Attributes | Description |
---|---|---|---|
value | <optional> | Date or FlexDateTime or year component | |
month | <optional> | Month number | |
day | <optional> | Day number | |
hours | <optional> | Hours | |
minutes | <optional> | Minutes |
// All components are undefined
new $k.FlexDateTime();
// Current date
new $k.FlexDateTime(new Date());
// 2007-06-03 21:48
new $k.FlexDateTime(2007, 6, 3, 21, 48);
Represents a flexible date/time without timezone that allowes certain degrees of imprecision.
FlexDateTime has the following components, which can be set to an integer or undefined:
year, month number, day number, hours, minutes.
Note that a FlexDateTime has no seconds.
Methods
(static) parse(string, languageopt)
Parse the date/time string. Both ISO 8601 and localized strings are supported.
Name | Type | Attributes | Description |
---|---|---|---|
string | string | The string representation | |
language | string | <optional> | Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated. |
If an invalid language was specified
If value is invalid
The parsed date/time
coversDate(date) → {boolean}
Returns true if the date is within the range of this flexible date
Name | Type | Description |
---|---|---|
date | date |
- Type:
- boolean
equals(value) → {boolean}
Returns true if the values are equal
Name | Type | Description |
---|---|---|
value | Another attribute value |
- Type:
- boolean
getDayNumber() → {number}
Returns the number of the day, e.g. 18 for 2011-03-18
- Type:
- number
getHours() → {number}
Returns the hours
- Type:
- number
getMinutes() → {number}
Returns the minutes
- Type:
- number
getMonthNumber() → {number}
Returns the number of the month. Unlike Date.prototype.month(), this is not the 0-based month index, so for January getMonthNumber() returns 1, not 0
- Type:
- number
getYear() → {number}
Returns the full year
- Type:
- number
maxDate() → {Date}
Returns the latest exact Javascript date that is within the range of this date/time, e.g. 2007-03-01T23:59:59.999 for the date 2007-03-01. Assumes that this is a date/time of the local timezone
- Type:
- Date
maxUTCDate() → {Date}
Returns the latest exact Javascript date that is within the range of this date/time, e.g. 2007-03-01T23:59:59.999 for the date 2007-03-01. Assumes that this is a date/time of the local timezone
- Type:
- Date
minDate() → {Date}
Returns the earliest exact Javascript date that is within the range of this date/time, e.g. 2007-03-01T0:00:00.0 for the date 2007-03-01. Assumes that this is a date/time of the local timezone
- Type:
- Date
minUTCDate() → {Date}
Returns the earliest exact Javascript date that is within the range of this date/time, e.g. 2007-03-01T0:00:00.0 for the date 2007-03-01. Assumes that this is an UTC date/time
- Type:
- Date
setDayNumber(day)
Sets the number of the day, e.g. 23 for 2012-05-23
Name | Type | Description |
---|---|---|
day | number |
setHours(hours)
Sets the hours
Name | Type | Description |
---|---|---|
hours | number |
setMinutes(minutes)
Sets the minutes.
Name | Type | Description |
---|---|---|
minutes | number |
setMonthNumber(month)
Set the number of the month. Unlike Date.prototype.month(), this is not the 0-based month index, so for January pass 1 to setMonthNumber() , not 0.
Name | Type | Description |
---|---|---|
month | number |
setValues(year, month, day, hours, minutes)
Sets all components of the FlexDateTime
Name | Type | Description |
---|---|---|
year | number | |
month | number | |
day | number | |
hours | number | |
minutes | number |
setYear(year)
Sets the full year. The year is not modified, so setYear(99) sets the year 99, not 1999.
Name | Type | Description |
---|---|---|
year | number |
toDate() → {Date}
Returns the date/time as a Javascript date object. Assumes that this is a date/time of the local timezone
- Type:
- Date
toJSON()
Returns a string representing the date/time, similar to Date.prototype.toJSON ( key )
toString(languageopt) → {string}
Returns the string representation. Equivalent to valueString()
Name | Type | Attributes | Description |
---|---|---|---|
language | string | <optional> | Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated. |
If an invalid language was specified
- Type:
- string
toUTC()
Returns the date/time as a UTC date/time Assumes that this is a local date/time
- Since
- 4.1.0
toUTCDate() → {Date}
Returns the date/time as a Javascript date object. Assumes that this is an UTC date/time
- Type:
- Date
valueOf() → {number}
Returns the internal millisecond value. Allows comparing date/time values, since the comparision operators call valueOf()
- Type:
- number
valueString(languageopt) → {string}
Returns the string representation
Name | Type | Attributes | Description |
---|---|---|---|
language | string | <optional> | Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated. |
If an invalid language was specified
- Type:
- string