Skip to content

formatCcsdsAsciiB

  • The core functions, which every industry uses.
formatCcsdsAsciiB(isoString: string, fractionalSecondDigits?: FractionalDigit): string

Write an instant as a CCSDS ASCII Time Code B string (YYYY-DDDThh:mm:ss.d…dZ, day of year).

  • CCSDS 301.0-B-4 §3.5.1.2. The instant is converted to UTC, and DDD is the UTC day of the year, 001 to 365, or 366 in a leap year. The Z is always written.
  • fractionalSecondDigits works as in Temporal’s toString: omitted or "auto" writes the shortest fraction that keeps every nanosecond, 0 writes no fraction and no period, and 1 to 9 write exactly that many digits. Extra digits are cut, never rounded, so the result never moves into the next second, day or year.
  • An inserted leap second is written as …T23:59:60Z on its own day. A second of 60 that is not one of the 27 inserted leap seconds (for example 2016-12-31T23:58:60Z) returns "".
  • "" for a date-time with no offset, a UTC year outside 0001 to 9999, a fractionalSecondDigits Temporal refuses (10, -1, null, "3"), and invalid input.
ParameterTypeDescription
isoStringstringISO 8601 instant string, with Z or an offset
fractionalSecondDigitsFractionalDigit"auto" (default) or 0 to 9

the Code B text, or "" on invalid input

import { formatCcsdsAsciiB } from "@northguild/gmt/timescale/format";
formatCcsdsAsciiB("1988-01-18T17:20:43.123456Z") // "1988-018T17:20:43.123456Z" — CCSDS's own example
output 

timescale/format/formatCcsdsAsciiB.ts

© 2026 NorthGuild · Licences

Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.