Options
All
  • Public
  • Public/Protected
  • All
Menu

Offset datetime object

  • Represents date and time with timezone.
  • Timezone is specified with offset from UTC in seconds. This offset can be negative or positive.
  • This class internally stores a LocalDateTime and offset number.

Hierarchy

  • OffsetDateTime

Index

Constructors

  • throws

    TypeError if type of arguments are invalid

    Parameters

    • localDateTime: LocalDateTime

      LocalDateTime object

    • offsetSeconds: number

      timezone offset in seconds. Must be in [-64800, 64800] range.

    Returns OffsetDateTime

Properties

localDateTime: LocalDateTime
offsetSeconds: number

Methods

  • asDate(): Date
  • Returns this offset datetime as Date. Note that the timezone information is not stored in Date objects and you effectively get a timestamp.(an instance in time without timezone)

    Returns Date

  • toString(): string
  • Returns ISO 8601 string with timezone of this instance.

    Returns string

    A string in the format yyyy-mm-ddTHH-mm-ss.SSS(Z | (+|-)HH:mm) Timezone is denoted either with Z or timezone string like +-HH:mm

  • from(year: number, month: number, date: number, hour: number, minute: number, second: number, nano: number, offsetSeconds: number): OffsetDateTime
  • Static constructor for convenient construction.

    throws

    TypeError if passed arguments are of wrong type

    throws

    RangeError if value of any of the arguments are invalid

    Parameters

    • year: number

      Must be between -999999999-999999999

    • month: number

      Must be between 1-12

    • date: number

      Must be between 1-31 depending on year and month

    • hour: number

      The hour-of-day to represent, from 0 to 23

    • minute: number

      The minute-of-hour to represent, from 0 to 59

    • second: number

      The second-of-minute to represent, from 0 to 59

    • nano: number

      The nano-of-second to represent, from 0 to 999,999,999

    • offsetSeconds: number

      timezone offset in seconds. Must be in [-64800, 64800] range.

    Returns OffsetDateTime

  • Constructs a new instance from Date and offset seconds.

    throws

    TypeError if a wrong type is passed as argument

    throws

    RangeError if an invalid argument value is passed

    Parameters

    • date: Date

      must be a valid Date. date.getTime() should be not NaN

    • offsetSeconds: number

      Offset in seconds, must be between [-64800, 64800]

    Returns OffsetDateTime

  • Constructs a new instance from ISO 8601 string. The string format is yyyy-mm-ddTHH-mm-ss.SSS(Z | (+|-)HH:mm).

    throws

    TypeError if passed value is not a string

    throws

    RangeError if passed string is invalid

    Parameters

    • isoString: string

      ISO 8601 string with timezone. If timezone is omitted, UTC is assumed

    Returns OffsetDateTime

Generated using TypeDoc