timedotgo
    Preparing search index...

    Interface Time

    A Time represents an instant in time with millisecond precision.

    interface Time {
        Add(d: number): Time;
        After(u: Time): boolean;
        Before(u: Time): boolean;
        Clock(): { hour: number; minute: number; second: number };
        Date(): { day: number; month: Month; year: number };
        Day(): number;
        Equal(u: Time): boolean;
        Format(layout: string): string;
        Hour(): number;
        In(location: string): Time;
        JSDate(): Date;
        Local(): Time;
        Millisecond(): number;
        Minute(): number;
        Month(): Month;
        Second(): number;
        String(): string;
        Sub(u: Time): number;
        Unix(): number;
        UnixMilli(): number;
        UTC(): Time;
        Weekday(): Weekday;
        Year(): number;
        YearDay(): number;
        Zone(): { name: string; offset: number };
    }
    Index

    Methods

    • Add returns the time t+d.

      Parameters

      • d: number

      Returns Time

    • After reports whether the time instant t is after u.

      Parameters

      Returns boolean

    • Before reports whether the time instant t is before u.

      Parameters

      Returns boolean

    • Clock returns the hour, minute, and second within the day specified by t.

      Returns { hour: number; minute: number; second: number }

    • Date returns the year, month, and day in which t occurs.

      Returns { day: number; month: Month; year: number }

    • Day returns the day of the month specified by t.

      Returns number

    • Equal reports whether t and u represent the same time instant. Two times can be equal even if they are in different locations. For example, 6:00 +0200 and 4:00 UTC are Equal.

      Parameters

      Returns boolean

    • Format returns a textual representation of the time value formatted according to the layout defined by the argument. See the documentation for the constant called Layout to see how to represent the layout format.

      Parameters

      • layout: string

      Returns string

    • Hour returns the hour within the day specified by t, in the range [0, 23].

      Returns number

    • In returns a copy of t representing the same time instant, but with the copy's location information set to loc for display purposes.

      Parameters

      • location: string

      Returns Time

    • JSDate returns a javascript date object at time t.

      Returns Date

    • Local returns t with the location set to local time.

      Returns Time

    • Millisecond returns the millisecond offset within the second specified by t, in the range [0, 1000].

      Returns number

    • Minute returns the minute offset within the hour specified by t, in the range [0, 59].

      Returns number

    • Second returns the second offset within the minute specified by t, in the range [0, 59].

      Returns number

    • String returns the time formatted using the format string

      "2006-01-02 15:04:05.999999999 -0700 MST"
      

      The returned string is meant for debugging; for a stable serialized representation, use t.Format with an explicit format string.

      Returns string

    • Sub returns the duration t-u.

      Parameters

      Returns number

    • Unix returns t as a Unix time, the number of seconds elapsed since January 1, 1970 UTC. The result does not depend on the location associated with t.

      Returns number

    • Returns number

    • Year returns the year in which t occurs.

      Returns number

    • YearDay returns the day of the year specified by t, in the range [1,365] for non-leap years, and [1,366] in leap years.

      Returns number

    • Zone computes the time zone in effect at time t, returning the abbreviated name of the zone (such as "CET") and its offset in seconds east of UTC.

      Returns { name: string; offset: number }