Fundamentals
    Preparing search index...

    Class TimeOnly

    Represents a time of day with no date and no time zone.

    Deliberately not a JavaScript Date. A Date needs a date, and a time of day has none: new Date('14:30:45') is not an instant pinned to some default day, it is Invalid Date. The value is destroyed outright rather than merely shifted, which makes this the starker of the two temporal cases.

    Index
    hour: number

    The hour, 0 through 23.

    millisecond: number

    The millisecond, 0 through 999.

    minute: number

    The minute, 0 through 59.

    second: number

    The second, 0 through 59.

    subMillisecondTicks: number

    The remaining 100 nanosecond ticks below the millisecond, 0 through 9999. Carries the last four digits of the seven-digit fraction a C# TimeOnly holds, so two times that differ below a millisecond stay different.

    "[typeKey]": "TimeOnly" = 'TimeOnly'
    • Determines whether this is the same time of day as another.

      Parameters

      • other: TimeOnly | null | undefined

        The other time.

      Returns boolean

      True when they are the same time.

    • Gets the ISO-8601 representation used when this is serialized as JSON.

      Without this, JSON.stringify falls back to enumerating hour, minute, second and millisecond, so a request body carries a component object where the server expects the scalar string.

      Returns string

      The string.

    • Gets the ISO-8601 representation: HH:mm:ss, or HH:mm:ss.fff when there is a millisecond part, or the full seven-digit HH:mm:ss.fffffff when there is a non-zero part below the millisecond. The seven-digit form is padded, never trimmed, so the two fractional forms are the only ones produced; the parser accepts 1-7 digits.

      Returns string

      The string.

    • Creates a TimeOnly from its parts.

      Parameters

      • hour: number

        The hour.

      • minute: number

        The minute.

      • second: number = 0

        The second.

      • millisecond: number = 0

        The millisecond.

      • subMillisecondTicks: number = 0

        The 100 nanosecond ticks below the millisecond, 0 through 9999.

      Returns TimeOnly

      The TimeOnly.

      If subMillisecondTicks is not a whole number from 0 through 9999.

    • Parses the ISO-8601 time of day the server sends, HH:mm, HH:mm:ss or HH:mm:ss.fffffff.

      Parameters

      • value: string

        The value to parse.

      Returns TimeOnly

      The TimeOnly.

      The seconds and the fraction are both optional because the server omits them when they are zero. The fraction carries up to seven digits, all of which are kept, so C# times that differ below a millisecond stay distinct. Components outside the ranges C# accepts are rejected.

      If the format is invalid or a component is out of range.