Repeating time period: consists of a reference date and a time length. This class accounts for leap seconds and leap days.

Constructors

  • Constructor LIMITATION: if dst equals RegularLocalTime, and unit is Second, Minute or Hour, then the amount must be a factor of 24. So 120 seconds is allowed while 121 seconds is not. This is due to the enormous processing power required by these cases. They are not implemented and you will get an assert.

    Parameters

    • reference: DateTime

      The reference date of the period. If the period is in Months or Years, and the day is 29 or 30 or 31, the results are maximised to end-of-month.

    • interval: Duration

      The interval of the period

    • Optional dst: PeriodDst

      Specifies how to handle Daylight Saving Time. Not relevant if the time zone of the reference datetime does not have DST. Defaults to RegularLocalTime.

    Returns Period

    Throws

    timezonecomplete.Argument.Dst for invalid dst value

    Throws

    timezonecomplete.Argument.Interval if amount not positive integer

    Throws

    timezonecomplete.Argument.Interval.NotImplemented if dst=RegularLocalTime and the interval is not a multiple of one day

  • Constructor LIMITATION: if dst equals RegularLocalTime, and unit is Second, Minute or Hour, then the amount must be a factor of 24. So 120 seconds is allowed while 121 seconds is not. This is due to the enormous processing power required by these cases. They are not implemented and you will get an assert.

    Parameters

    • reference: DateTime

      The reference of the period. If the period is in Months or Years, and the day is 29 or 30 or 31, the results are maximised to end-of-month.

    • amount: number

      The amount of units.

    • unit: TimeUnit

      The unit.

    • Optional dst: PeriodDst

      Specifies how to handle Daylight Saving Time. Not relevant if the time zone of the reference datetime does not have DST. Defaults to RegularLocalTime.

    Returns Period

    Throws

    timezonecomplete.Argument.Amount for invalid amount

    Throws

    timezonecomplete.Argument.Unit for invalid time unit

    Throws

    timezonecomplete.Argument.Interval if amount not positive integer

    Throws

    timezonecomplete.Argument.Interval.NotImplemented if dst=RegularLocalTime and the interval is not a multiple of one day

    Throws

    timezonecomplete.Argument.Dst for invalid dst value

  • Constructor LIMITATION: if dst equals RegularLocalTime, and unit is Second, Minute or Hour, then the amount must be a factor of 24. So 120 seconds is allowed while 121 seconds is not. This is due to the enormous processing power required by these cases. They are not implemented and you will get an assert.

    Parameters

    • json: PeriodJson

      period represented as JSON object

    Returns Period

    Throws

    timezonecomplete.Argument.Json for invalid JSON (missing reference, unparseable reference or interval)

    Throws

    timezonecomplete.Argument.Interval if amount not positive integer

    Throws

    timezonecomplete.Argument.Interval.NotImplemented if dst=RegularLocalTime and the interval is not a multiple of one day

Properties

kind: string = "Period"

Allow not using instanceof

Methods

  • The amount of units of the interval

    Returns number

    Throws

    nothing

  • Returns true iff this period has the same effect as the given one. i.e. a period of 24 hours is equal to one of 1 day if they have the same UTC reference moment and same dst.

    Parameters

    Returns boolean

    Throws

    timezonecomplete.UnawareToAwareConversion if not both other#reference() and the reference date are both aware or unaware of time zone

    Throws

    timezonecomplete.NotFound.Zone if the UTC time zone doesn't exist in the time zone database

  • The first occurrence of the period greater than the given date. The given date need not be at a period boundary. Pre: the fromdate and reference date must either both have timezones or not

    Parameters

    Returns DateTime

    the first date matching the period after fromDate, given in the same zone as the fromDate.

    Throws

    timezonecomplete.UnawareToAwareConversion if not both fromdate and the reference date are both aware or unaware of time zone

    Throws

    timezonecomplete.NotFound.Zone if the UTC time zone doesn't exist in the time zone database

  • The last occurrence of the period less than the given date. The given date need not be at a period boundary. Pre: the fromdate and the period reference date must either both have timezones or not

    Parameters

    Returns DateTime

    the last date matching the period before fromDate, given in the same zone as the fromDate.

    Throws

    timezonecomplete.UnawareToAwareConversion if not both from and the reference date are both aware or unaware of time zone

    Throws

    timezonecomplete.NotFound.Zone if the UTC time zone doesn't exist in the time zone database

  • Returns the next timestamp in the period. The given timestamp must be at a period boundary, otherwise the answer is incorrect. This function has MUCH better performance than findFirst. Returns the datetime "count" times away from the given datetime.

    Parameters

    • prev: DateTime

      Boundary date. Must have a time zone (any time zone) iff the period reference date has one.

    • count: number = 1

      Number of periods to add. Optional. Must be an integer number, may be positive or negative, default 1

    Returns DateTime

    (prev + count * period), in the same timezone as prev.

    Throws

    timezonecomplete.Argument.Prev if prev is undefined

    Throws

    timezonecomplete.Argument.Count if count is not an integer number

  • Returns the previous timestamp in the period. The given timestamp must be at a period boundary, otherwise the answer is incorrect.

    Parameters

    • next: DateTime
    • count: number = 1

      Number of periods to subtract. Optional. Must be an integer number, may be negative.

    Returns DateTime

    (next - count * period), in the same timezone as next.

    Throws

    timezonecomplete.Argument.Next if prev is undefined

    Throws

    timezonecomplete.Argument.Count if count is not an integer number

  • Returns true iff this period was constructed with identical arguments to the other one.

    Parameters

    Returns boolean

    Throws

    nothing

  • Checks whether the given date is on a period boundary (expensive!)

    Parameters

    Returns boolean

    Throws

    timezonecomplete.UnawareToAwareConversion if not both occurrence and the reference date are both aware or unaware of time zone

    Throws

    timezonecomplete.NotFound.Zone if the UTC time zone doesn't exist in the time zone database

  • Returns an ISO duration string e.g. 2014-01-01T12:00:00.000+01:00/P1H 2014-01-01T12:00:00.000+01:00/PT1M (one minute) 2014-01-01T12:00:00.000+01:00/P1M (one month)

    Returns string

    Throws

    nothing

  • A string representation e.g. "10 years, referenceing at 2014-03-01T12:00:00 Europe/Amsterdam, keeping regular intervals".

    Returns string

    Throws

    nothing

Generated using TypeDoc