Home Reference Source
public class | source

DateTime

Represents an instant capturing the date, the time and the timezone identifier. Created {@ DateTime} objects are frozen with Object.freeze() in constructor and thus immutable.

Static Method Summary

Static Public Methods
public static

fromStandardDate(standardDate: global.Date, nanosecond: NumberOrInteger | undefined): DateTime

Create a DateTime object from the given standard JavaScript Date and optional nanoseconds.

Constructor Summary

Public Constructor
public

constructor(year: NumberOrInteger, month: NumberOrInteger, day: NumberOrInteger, hour: NumberOrInteger, minute: NumberOrInteger, second: NumberOrInteger, nanosecond: NumberOrInteger, timeZoneOffsetSeconds: NumberOrInteger, timeZoneId: string | null)

Member Summary

Public Members
public

day: NumberOrInteger

The day.

public

hour: NumberOrInteger

The hour.

public

minute: NumberOrInteger

The minute.

public

month: NumberOrInteger

The month.

public

nanosecond: NumberOrInteger

The nanosecond.

public

second: NumberOrInteger

The second.

public

timeZoneId: string

The time zone id.

public

timeZoneOffsetSeconds: NumberOrInteger

The time zone offset in seconds.

public

year: NumberOrInteger

The year.

Method Summary

Public Methods
public

toStandardDate(): StandardDate

Convert date to standard JavaScript Date.

Static Public Methods

public static fromStandardDate(standardDate: global.Date, nanosecond: NumberOrInteger | undefined): DateTime source

Create a DateTime object from the given standard JavaScript Date and optional nanoseconds.

Params:

NameTypeAttributeDescription
standardDate global.Date

The standard JavaScript date to convert.

nanosecond NumberOrInteger | undefined

The optional amount of nanoseconds.

Return:

DateTime

New DateTime.

Public Constructors

public constructor(year: NumberOrInteger, month: NumberOrInteger, day: NumberOrInteger, hour: NumberOrInteger, minute: NumberOrInteger, second: NumberOrInteger, nanosecond: NumberOrInteger, timeZoneOffsetSeconds: NumberOrInteger, timeZoneId: string | null) source

Params:

NameTypeAttributeDescription
year NumberOrInteger

The year for the new date-time.

month NumberOrInteger

The month for the new date-time.

day NumberOrInteger

The day for the new date-time.

hour NumberOrInteger

The hour for the new date-time.

minute NumberOrInteger

The minute for the new date-time.

second NumberOrInteger

The second for the new date-time.

nanosecond NumberOrInteger

The nanosecond for the new date-time.

timeZoneOffsetSeconds NumberOrInteger

The time zone offset in seconds. Either this argument or timeZoneId should be defined. Value represents the difference, in seconds, from UTC to local time. This is different from standard JavaScript Date.getTimezoneOffset() which is the difference, in minutes, from local time to UTC.

timeZoneId string | null

The time zone id for the new date-time. Either this argument or timeZoneOffsetSeconds should be defined.

Public Members

public day: NumberOrInteger source

The day.

public hour: NumberOrInteger source

The hour.

public minute: NumberOrInteger source

The minute.

public month: NumberOrInteger source

The month.

public nanosecond: NumberOrInteger source

The nanosecond.

public second: NumberOrInteger source

The second.

public timeZoneId: string source

The time zone id.

Either this or timeZoneOffsetSeconds is defined.

public timeZoneOffsetSeconds: NumberOrInteger source

The time zone offset in seconds.

Either this or timeZoneId is defined.

public year: NumberOrInteger source

The year.

Public Methods

public toStandardDate(): StandardDate source

Convert date to standard JavaScript Date.

Return:

StandardDate

Standard JavaScript Date at the defined time zone offset

Throw:

Error

If the time zone offset is not defined in the object.