Date
Represents an instant capturing the date, but not the time, nor the timezone.
Created Date objects are frozen with Object.freeze()
in constructor and thus immutable.
Static Method Summary
Static Public Methods | ||
public static |
fromStandardDate(standardDate: global.Date): Date this method was deprecated. use {@link fromStandardDateLocal} which is a drop in replacement, or {@link fromStandardDateUTC} which takes the Year, Month and Date from UTC rather than Local time
Create a Date object from the given standard JavaScript |
|
public static |
fromStandardDateLocal(standardDate: global.Date): Date Create a Date object from the given standard JavaScript |
|
public static |
fromStandardDateUTC(standardDate: global.Date): Date Create a Date object from the given standard JavaScript |
Constructor Summary
Public Constructor | ||
public |
constructor(year: NumberOrInteger, month: NumberOrInteger, day: NumberOrInteger) |
Member Summary
Public Members | ||
public |
day: NumberOrInteger The day. |
|
public |
month: NumberOrInteger The month. |
|
public |
year: NumberOrInteger The year. |
Method Summary
Public Methods | ||
public |
toStandardDate(): StandardDate Convert date to standard JavaScript |
Static Public Methods
public static fromStandardDate(standardDate: global.Date): Date source
Create a Date object from the given standard JavaScript Date
.
Hour, minute, second and millisecond components of the given date are ignored.
NOTE: the function toStandardDate and fromStandardDate are not inverses of one another. fromStandardDate takes the Day, Month and Year in local time from the supplied JavaScript Date object, while toStandardDate creates a new JavaScript Date object at midnight UTC.
Params:
Name | Type | Attribute | Description |
standardDate | global.Date | The standard JavaScript date to convert. |
public static fromStandardDateLocal(standardDate: global.Date): Date source
Create a Date object from the given standard JavaScript Date
using the Year, Month and Date in Local Time.
Hour, minute, second and millisecond components of the given date are ignored.
NOTE: this function and toStandardDate are not inverses of one another. This takes the Day, Month and Year in local time from the supplied JavaScript Date object, while toStandardDate creates a new JavaScript Date object at midnight UTC. For a more global approach, use fromStandardDateUTC, which reads the date in UTC time.
Params:
Name | Type | Attribute | Description |
standardDate | global.Date | The standard JavaScript date to convert. |
Example:
fromStandardDateLocal(new Date("2010-10-10T00:00:00")) // Will create a date at 2010-10-10 as JS Dates are created at local time by default
fromStandardDateLocal(new Date("2010-10-10T00:00:00Z")) // This may cause issues as this date is created at UTC with the trailing "Z"
public static fromStandardDateUTC(standardDate: global.Date): Date source
Create a Date object from the given standard JavaScript Date
using the Year, Month and Date in UTC time.
Hour, minute, second and millisecond components of the given date are ignored.
Params:
Name | Type | Attribute | Description |
standardDate | global.Date | The standard JavaScript date to convert. |
Example:
fromStandardDateUTC(new Date("2010-10-10T00:00:00")) // This may cause issues as JS Dates are created at local time by default
fromStandardDateUTC(new Date("2010-10-10T00:00:00Z")) // Will create a date at 2010-10-10 as this date is created at UTC with the trailing "Z"
Public Constructors
public constructor(year: NumberOrInteger, month: NumberOrInteger, day: NumberOrInteger) source
Params:
Name | Type | Attribute | Description |
year | NumberOrInteger | The year for the new local date. |
|
month | NumberOrInteger | The month for the new local date. |
|
day | NumberOrInteger | The day for the new local date. |
Public Members
Public Methods
public toStandardDate(): StandardDate source
Convert date to standard JavaScript Date
.
The time component of the returned Date
is set to midnight
and the time zone is set to UTC.
Return:
StandardDate | Standard JavaScript |