Extends
Properties
formats :Object.<string, string>static
#
Default format specifications.
See the format
parameter in mw.widgets.datetime.DateTimeFormatter
.
Type:
Methods
adjustComponent(date, component, delta, mode) → {Date}
#
Adjust a date.
Parameters:
Name | Type | Description |
---|---|---|
date |
Date
|
null
|
To be adjusted |
component |
string | To adjust |
delta |
number | Adjustment amount |
mode |
string | Adjustment mode:
|
- Overrides:
- Source:
Returns:
Adjusted date
- Type
- Date
datePartIsEqual(date1, date2) → {boolean}
#
Test whether the date parts of two Dates are equal.
Parameters:
- Inherited from:
- Source:
Returns:
- Type
- boolean
formatSpecValue(v) → {string}protected
#
Format a value for a field specification.
'this' must be the field specification object. The intention is that you could just assign this function as the 'formatValue' for each field spec.
Besides the publicly-documented fields, uses the following:
- values: Enumerated values for the field
- zeropad: Whether to pad the number with zeros.
Parameters:
Name | Type | Description |
---|---|---|
v |
any |
- Inherited from:
- Source:
Returns:
- Type
- string
getCalendarData(current) → {CalendarGridData}
#
Get data for a calendar grid.
A "day" object is:
- display: {string} Display text for the day.
- date: {Date} Date to use when the day is selected.
- extra: {string|null} 'prev' or 'next' on days used to fill out the weeks at the start and end of the month.
In any one result object, 'extra' + 'display' will always be unique.
Parameters:
Name | Type | Description |
---|---|---|
current |
Date
|
null
|
Current date |
- Overrides:
- Source:
Returns:
Data
- Type
- CalendarGridData
getCalendarHeadings() → {Array}
#
Get the column headings (weekday abbreviations) for a calendar grid.
Null-valued columns are hidden if getCalendarData() returns no "day" object for all days in that column.
- Overrides:
- Source:
Returns:
string or null
- Type
- Array
getComponentsFromDate(date) → {Object}
#
Get components from a Date object.
Components are:
- Year {number}
- Season {number} 1-5
- Day {number|string} 1-73 or 'tib'
- DOW {number} 0-4, or -1 on St. Tib's Day
- Hour {number} 0-23
- Minute {number} 0-59
- Second {number} 0-59
- Millisecond {number} 0-999
- intercalary {string} '1' on St. Tib's Day
Parameters:
Name | Type | Description |
---|---|---|
date |
Date
|
null
|
- Overrides:
- Source:
Returns:
Components
- Type
- Object
getDateFromComponents(components) → {Date}
#
getFieldForTag(tag, params) → {FieldSpecificationObject}protected
#
Turn a tag into a field specification object.
Additional fields implemented here are:
- ${year|#}: Year as a number
- ${season|#}: Season as a number
- ${season|full}: Season as a string
- ${day|#}: Day of the month as a number
- ${day|0}: Day of the month as a number with leading 0
- ${dow|full}: Day of the week as a string
- ${hour|#}: Hour as a number
- ${hour|0}: Hour as a number with leading 0
- ${minute|#}: Minute as a number
- ${minute|0}: Minute as a number with leading 0
- ${second|#}: Second as a number
- ${second|0}: Second as a number with leading 0
- ${millisecond|#}: Millisecond as a number
- ${millisecond|0}: Millisecond as a number, zero-padded to 3 digits
Parameters:
- Overrides:
- Source:
Returns:
Field specification object, or null if the tag+params are unrecognized.
getFieldSpec() → {Array}
#
Fetch the field specification array for this object.
See parseFieldSpec
for details on the return value structure.
- Inherited from:
- Source:
Returns:
- Type
- Array
getLocal() → {boolean}
#
Whether dates are in local time or UTC.
- Inherited from:
- Source:
Returns:
True if local time
- Type
- boolean
localChangesDatePart(date) → {boolean}
#
mergeDateAndTime(datepart, timepart) → {Date}
#
Create a new Date by merging the date part from one with the time part from another.
Parameters:
- Inherited from:
- Source:
Returns:
- Type
- Date
Create a new Date by merging the date part from one with the time part from another.
parseFieldSpec(format) → {Array}protected
#
Parse a format string into a field specification.
The input is a string containing tags formatted as ${tag|param|param...}
(for editable fields) and $!{tag|param|param...} (for non-editable fields).
Most tags are defined by getFieldForTag
, but a few
are defined here:
- ${intercalary|X|text}: Text that is only displayed when the 'intercalary' component is X.
- ${not-intercalary|X|text}: Text that is displayed unless the 'intercalary' component is X.
Elements of the returned array are strings or objects. Strings are meant to
be displayed as-is. Objects are as returned by getFieldForTag
.
Parameters:
Name | Type | Description |
---|---|---|
format |
string |
- Inherited from:
- Source:
Returns:
- Type
- Array
parseSpecValue(v) → {number|string|null
}protected
#
null
}protected
#
Parse a value for a field specification.
'this' must be the field specification object. The intention is that you could just assign this function as the 'parseValue' for each field spec.
Besides the publicly-documented fields, uses the following:
- values: Enumerated values for the field
Parameters:
Name | Type | Description |
---|---|---|
v |
string |
- Inherited from:
- Source:
Returns:
sameCalendarGrid(date1, date2) → {boolean}
#
Test whether two dates are in the same calendar grid.
Parameters:
- Overrides:
- Source:
Returns:
- Type
- boolean
timePartIsEqual(date1, date2) → {boolean}
#
Test whether the time parts of two Dates are equal.
Parameters:
- Inherited from:
- Source:
Returns:
- Type
- boolean
toggleLocal([flag]) → {mw.widgets.datetime.DateTimeFormatter}chainable
#
Toggle whether dates are in local time or UTC.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
flag |
boolean |
optional |
Set the flag instead of toggling it |
- Inherited from:
- Source: