Time Commands¶
Time system operations, conversions, and epoch manipulation.
Overview¶
The time command group provides:
- Conversion between time formats (MJD, JD, ISO-8601, GPS)
- Conversion between time systems (UTC, TAI, GPS, UT1, TT)
- Time arithmetic (adding/subtracting durations)
- Time range generation
Commands¶
convert¶
Convert between time formats and time systems.
Syntax:
Arguments:
- EPOCH - Time value to convert
- INPUT_FORMAT - Format of input: mjd, jd, string, gps_date, gps_nanoseconds
- OUTPUT_FORMAT - Desired output format (same options as input)
Options:
- --input-time-system [UTC|GPS|TAI|UT1|TT] - Time system of input
- --output-time-system [UTC|GPS|TAI|UT1|TT] - Time system of output
Examples:
Convert ISO-8601 string to Modified Julian Date:
brahe time convert "2024-01-01T00:00:00Z" string mjd --input-time-system UTC --output-time-system UTC
Convert MJD to Julian Date:
Output:Convert between time systems (UTC to TAI):
brahe time convert "2024-01-01T00:00:00Z" string string --input-time-system UTC --output-time-system TAI
Convert GPS time to UTC:
add¶
Add a time offset to an epoch.
Syntax:
Arguments:
- EPOCH - Starting epoch (ISO-8601 string, MJD, or JD)
- SECONDS - Number of seconds to add (can be negative)
Options:
- --output-format [mjd|jd|string|gps_date|gps_nanoseconds] - Output format (default: string)
- --output-time-system [UTC|GPS|TAI|UT1|TT] - Output time system (default: UTC)
Examples:
Add 1 hour (3600 seconds):
Output:Add 1 day (86400 seconds):
Output:Subtract 30 minutes (negative seconds):
Output:Output as MJD:
Output:time-system-offset¶
Calculate the offset between two time systems at a given epoch.
Syntax:
Arguments:
- EPOCH - Epoch to calculate offset at (ISO-8601 string)
- SOURCE - Source time system: UTC, GPS, TAI, UT1, TT
- TARGET - Target time system (same options)
Examples:
UTC to TAI offset:
Output: (TAI is 37 seconds ahead of UTC in 2024)GPS to UTC offset:
Output: (GPS is 18 seconds behind UTC... wait, that's the leap second offset)TAI to TT offset:
Output: (TT is always 32.184 seconds ahead of TAI)range¶
Generate a sequence of epochs over a time range.
Syntax:
Arguments:
- EPOCH_START - Start of time range (ISO-8601 string)
- EPOCH_END - End of time range (ISO-8601 string)
- STEP - Step size in seconds
Examples:
Generate epochs every 30 minutes for 1 hour:
Output:Generate epochs every 6 hours for 1 day:
Output:2024-01-01 00:00:00.000 UTC
2024-01-01 06:00:00.000 UTC
2024-01-01 12:00:00.000 UTC
2024-01-01 18:00:00.000 UTC
Generate epochs every minute for 5 minutes:
Output:2024-01-01 12:00:00.000 UTC
2024-01-01 12:01:00.000 UTC
2024-01-01 12:02:00.000 UTC
2024-01-01 12:03:00.000 UTC
2024-01-01 12:04:00.000 UTC
Time Systems¶
UTC (Coordinated Universal Time)¶
- Civil time standard
- Includes leap seconds
- Most common for human-readable timestamps
TAI (International Atomic Time)¶
- Continuous atomic time scale
- No leap seconds
- Currently 37 seconds ahead of UTC (as of 2024)
GPS (Global Positioning System Time)¶
- Used by GPS satellites
- Started at 1980-01-06 00:00:00 UTC
- 19 seconds behind TAI (fixed offset)
UT1 (Universal Time 1)¶
- Based on Earth's rotation
- Irregular due to Earth rotation variations
- Requires Earth Orientation Parameters (EOP)
TT (Terrestrial Time)¶
- Ideal time for Earth-based observations
- Always 32.184 seconds ahead of TAI
Offset Relationships¶
TT = TAI + 32.184s
TAI = GPS + 19s
TAI = UTC + (leap seconds, currently 37s)
UT1 = UTC + (DUT1, from EOP data)
Time Formats¶
ISO-8601 String (string)¶
Human-readable format with timezone:
Modified Julian Date (mjd)¶
Days since 1858-11-17 00:00:00 UTC:
60310.0 # 2024-01-01 00:00:00 UTC
60310.5 # 2024-01-01 12:00:00 UTC
60310.25 # 2024-01-01 06:00:00 UTC
Julian Date (jd)¶
Days since -4712-01-01 12:00:00 UTC:
Relationship: JD = MJD + 2400000.5
GPS Date (gps_date)¶
GPS week number and seconds:
GPS Nanoseconds (gps_nanoseconds)¶
Nanoseconds since GPS epoch (1980-01-06 00:00:00 UTC):
Common Workflows¶
Mission Planning Timeline¶
#!/bin/bash
# Create mission timeline with 1-hour intervals
START="2024-06-01T00:00:00Z"
END="2024-06-01T24:00:00Z"
STEP=3600 # 1 hour
echo "Mission timeline:"
brahe time range "$START" "$END" "$STEP"
Time System Comparison¶
#!/bin/bash
# Compare all time systems at a specific epoch
EPOCH="2024-01-01T00:00:00Z"
echo "Epoch: $EPOCH"
echo "UTC to TAI: $(brahe time time-system-offset "$EPOCH" UTC TAI)s"
echo "UTC to GPS: $(brahe time time-system-offset "$EPOCH" UTC GPS)s"
echo "UTC to TT: $(brahe time time-system-offset "$EPOCH" UTC TT)s"
Satellite Pass Duration¶
#!/bin/bash
# Calculate pass duration
START="2024-01-01T14:23:15Z"
END="2024-01-01T14:35:42Z"
# Convert to MJD
MJD_START=$(brahe time convert "$START" string mjd --input-time-system UTC --output-time-system UTC)
MJD_END=$(brahe time convert "$END" string mjd --input-time-system UTC --output-time-system UTC)
# Calculate duration (MJD is in days)
DURATION=$(echo "($MJD_END - $MJD_START) * 86400" | bc)
echo "Pass duration: ${DURATION} seconds"
Propagation Timeline¶
#!/bin/bash
# Generate epochs for 24-hour propagation with 10-minute steps
START="2024-01-01T00:00:00Z"
DURATION_HOURS=24
STEP_SECONDS=600 # 10 minutes
# Calculate end time
END=$(brahe time add "$START" $((DURATION_HOURS * 3600)) --output-format string)
# Generate timeline
brahe time range "$START" "$END" "$STEP_SECONDS" > propagation_epochs.txt
Tips¶
Leap Seconds¶
UTC includes leap seconds, which are added irregularly: - As of 2024-01-01: 37 leap seconds have been added since 1972 - TAI - UTC = 37 seconds - GPS is 19 seconds behind TAI (fixed)
Use TAI or GPS for continuous time calculations without discontinuities.
High-Precision Timestamps¶
ISO-8601 strings support nanosecond precision:
Negative Time Offsets¶
Use negative seconds to subtract time:
Batch Processing¶
Use shell loops for batch time conversions:
# Convert multiple epochs
for epoch in "2024-01-01T00:00:00Z" "2024-06-01T00:00:00Z" "2024-12-31T00:00:00Z"; do
echo "$epoch -> $(brahe time convert "$epoch" string mjd --input-time-system UTC --output-time-system UTC)"
done
See Also¶
- Earth Orientation Data - EOP and UT1
- Epoch API - Python Epoch class
- EOP CLI - Earth Orientation Parameters
- Transform CLI - Coordinate transformations (require epochs)