Astro~/0.3
** CLI / astro time * PAGE 14 / 22
** Astro * CLI
** /cli/time

astro time

CCSDS time codes, encode, decode, inspect, now.

CCSDS Time Code Format operations: encode, decode, and inspect CCSDS time codes (CCSDS 301.0-B-4). Supports CUC, CDS, CCS, and ASCII formats.

Subcommands

CommandDescription
astro time decodeDecode a binary/hex time code into a human-readable timestamp
astro time encodeEncode a timestamp into a CCSDS time code
astro time inspectAnnotated P-field and T-field breakdown with hex dump
astro time nowEncode the current UTC time in all supported formats

Supported formats

FormatCodec FlagDescription
CUCcucCCSDS Unsegmented Time Code, coarse + fine seconds since epoch
CDScdsCCSDS Day Segmented, day count + milliseconds of day
CCSccsCCSDS Calendar Segmented, calendar fields (year, day, hour, etc.)
ASCII Type Aascii-aISO 8601 calendar date (YYYY-MM-DDThh:mm:ss.dZ)
ASCII Type Bascii-bISO 8601 ordinal date (YYYY-DDDThh:mm:ss.dZ)

For binary formats (CUC, CDS, CCS), the codec is auto-detected from the P-field when --codec is omitted.


astro time decode

Decode a CCSDS time code into a human-readable timestamp.

astro time decode [file] [flags]

Flags

FlagDefaultDescription
--inputhexInput format: hex or bin
--formattextOutput format: text or json
--codecautoTime code format: cuc, cds, ccs, ascii-a, ascii-b

Examples

# Decode a CUC time code (auto-detected from P-field)
echo "1c7e67d175" | astro time decode --input hex

# Decode a CDS time code
echo "405fe102af5508" | astro time decode --codec cds --input hex

# Decode with JSON output
echo "1c7e67d175" | astro time decode --input hex --format json

# Decode an ASCII Type A time string
echo "2025-03-15T12:30:45.123Z" | astro time decode --codec ascii-a

astro time encode

Convert a timestamp into a CCSDS time code.

astro time encode [flags]

Flags

FlagDefaultDescription
--codeccucTime code format: cuc, cds, ccs, ascii-a, ascii-b
--timenowTimestamp to encode (RFC3339 or now)
--formathexOutput format: text, json, or hex

CUC-specific flags

FlagDefaultDescription
--coarse-bytes4Coarse time octets (1-4)
--fine-bytes0Fine time octets (0-3)

CDS-specific flags

FlagDefaultDescription
--day-bytes2Day segment width (2 or 3)
--subms-bytes0Sub-millisecond width (0, 2, or 4)

CCS-specific flags

FlagDefaultDescription
--month-dayfalseUse month/day variant instead of day-of-year
--sub-sec-bytes0Sub-second octets (0-6)

ASCII-specific flags

FlagDefaultDescription
--precision3Fractional second digits (0-9)

Examples

# Encode current time as CUC
astro time encode --codec cuc

# Encode a specific timestamp as CDS
astro time encode --codec cds --time "2025-03-15T12:30:45Z"

# Encode as CCS with month/day variant
astro time encode --codec ccs --time "2025-03-15T12:30:45Z" --month-day

# Encode as ASCII Type A
astro time encode --codec ascii-a --time "2025-03-15T12:30:45.123Z"

# Encode CUC with fine time resolution
astro time encode --codec cuc --time "2025-03-15T12:30:45.5Z" --fine-bytes 2

# JSON output
astro time encode --codec cuc --format json

astro time inspect

Display an annotated breakdown of a CCSDS time code, including P-field details, T-field segments, resolved timestamp, and a hex dump.

astro time inspect [file] [flags]

Flags

FlagDefaultDescription
--inputhexInput format: hex or bin
--codecautoTime code format: cuc, cds, ccs

Examples

# Inspect a CUC time code
echo "1c7e67d175" | astro time inspect --input hex

# Inspect a CDS time code
echo "405fe102af5508" | astro time inspect --codec cds --input hex

Sample Output

Time Code Inspector
────────────────────────────────────────────────────────────
P-Field (1 byte)
  Extension ............ false
  Time Code ID ......... 1 (CUC Level 1)
  Detail Bits .......... 0xC
────────────────────────────────────────────────────────────
CUC T-Field
  Level ................ Level 1 (CCSDS epoch: 1958-01-01)
  Coarse Octets ........ 4
  Fine Octets .......... 0
  Coarse Time .......... 2120733045 s
  Resolved Time ........ 2025-03-15T12:30:45Z
────────────────────────────────────────────────────────────
Raw (5 bytes)
  0000  1c 7e 67 d1 75                                    |.~g.u|

astro time now

Encode the current UTC time in all supported CCSDS formats at once.

astro time now [flags]

Flags

FlagDefaultDescription
--codecallSpecific format: cuc, cds, ccs, ascii-a, ascii-b
--formattextOutput format: text or json

Examples

# Show current time in all formats
astro time now

# Show only CUC
astro time now --codec cuc

# JSON output with all formats
astro time now --format json

Sample Output

Current UTC: 2025-03-15T12:30:45.123456Z
────────────────────────────────────────────────────────────
CUC .... 1e7e67d1751fca
CDS .... 40615a02af5508
CCS .... 5a202500741230451234
ASCII-A  2025-03-15T12:30:45.123Z
ASCII-B  2025-074T12:30:45.123Z

Piping

# Encode -> Decode round-trip
astro time encode --codec cuc --time "2025-03-15T12:30:45Z" | astro time decode --input hex --format json

# Encode -> Inspect
astro time encode --codec cds --time "2025-03-15T12:30:45Z" | astro time inspect --input hex

See also: the protocol page for the standard and the Go API, and the conformance statement for what is and is not implemented.