Class TimezoneDate

A date implementation with timezone info, just like Ruby date

Implementation:

  • create a Date offset by it's timezone difference, avoiding overriding a bunch of methods
  • rewrite getTimezoneOffset() to trick strftime

Hierarchy

  • TimezoneDate

Implements

  • LiquidDate

Constructors

Properties

date: Date
displayDate: Date
timezoneName: string
timezoneOffset: number

Methods

  • Parameters

    • Optional locale: string

    Returns string

  • Parameters

    • Optional locale: string
    • Optional init: any

    Returns string

  • Parameters

    • Optional locale: string

    Returns string

  • Create a Date object fixed to it's declared Timezone. Both

    • 2021-08-06T02:29:00.000Z and
    • 2021-08-06T02:29:00.000+08:00 will always be displayed as
    • 2021-08-06 02:29:00 regardless timezoneOffset in JavaScript realm

    The implementation hack: Instead of calling .getMonth()/.getUTCMonth() respect to preserveTimezones, we create a different Date to trick strftime, it's both simpler and more performant. Given that a template is expected to be parsed fewer times than rendered.

    Parameters

    • dateString: string

    Returns LiquidDate

  • Parameters

    • timezoneName: string
    • date: Date = ...

    Returns number

Generated using TypeDoc