-
-
Notifications
You must be signed in to change notification settings - Fork 242
Open
Description
The following methods on the Time object don't seem to honor the %f directive to print microseconds. They instead seem to generate a timezone string. Example code and its output below:
tai_strftime(format='%Y-%m-%d %H:%M:%S TAI')
tt_strftime(format='%Y-%m-%d %H:%M:%S TT')
tdb_strftime(format='%Y-%m-%d %H:%M:%S TDB')
ut1_strftime(format='%Y-%m-%d %H:%M:%S UT1')
Example code:
from skyfield.api import load
from skyfield import __version__;
import pytz
print(__version__)
ts = load.timescale()
t = ts.now()
print("Basic time representation:")
print(f"Time object: {t}")
print(f"UTC ISO: {t.utc_iso()}")
print("\nTAI (International Atomic Time):")
print(f"TAI Julian date: {t.tai}")
print(f"TAI calendar: {t.tai_calendar()}")
print(f"TAI formatted: {t.tai_strftime('%Y-%m-%dT%H:%M:%S.%fZ')}")
print("\nTT (Terrestrial Time):")
print(f"TT Julian date: {t.tt}")
print(f"TT calendar: {t.tt_calendar()}")
print(f"TT formatted: {t.tt_strftime('%Y-%m-%dT%H:%M:%S.%fZ')}")
print("\nTDB (Barycentric Dynamical Time):")
print(f"TDB Julian date: {t.tdb}")
print(f"TDB calendar: {t.tdb_calendar()}")
print(f"TDB formatted: {t.tdb_strftime('%Y-%m-%dT%H:%M:%S.%fZ')}")
print("\nUT1 (Universal Time 1):")
print(f"UT1 Julian date: {t.ut1}")
print(f"UT1 calendar: {t.ut1_calendar()}")
print(f"UT1 formatted: {t.ut1_strftime('%Y-%m-%dT%H:%M:%S.%fZ')}")
tz = pytz.timezone("Asia/Kolkata")
dt, leap_second = t.astimezone_and_leap_second(tz)
print(f"\nLocal time ({tz}): {dt}")
print(f"Leap second: {leap_second}")
Output:
1.53
Basic time representation:
Time object: <Time tt=2460809.719177017>
UTC ISO: 2025-05-14T05:14:28Z
TAI (International Atomic Time):
TAI Julian date: 2460809.7188045173
TAI calendar: (np.int64(2025), np.int64(5), np.int64(14), np.int64(5), np.int64(15), np.float64(4.710280000013881))
TAI formatted: 2025-05-14T05:15:04.India Standard TimeZ
TT (Terrestrial Time):
TT Julian date: 2460809.719177017
TT calendar: (np.int64(2025), np.int64(5), np.int64(14), np.int64(5), np.int64(15), np.float64(36.89428000000407))
TT formatted: 2025-05-14T05:15:36.India Standard TimeZ
TDB (Barycentric Dynamical Time):
TDB Julian date: 2460809.719177032
TDB calendar: (np.int64(2025), np.int64(5), np.int64(14), np.int64(5), np.int64(15), np.float64(36.89555112553717))
TDB formatted: 2025-05-14T05:15:36.India Standard TimeZ
UT1 (Universal Time 1):
UT1 Julian date: 2460809.71837652
UT1 calendar: (np.int64(2025), np.int64(5), np.int64(14), np.int64(5), np.int64(14), np.float64(27.731326840370457))
UT1 formatted: 2025-05-14T05:14:27.India Standard TimeZ
Local time (Asia/Kolkata): 2025-05-14 10:44:27.710280+05:30
Leap second: 0
Note that %f results in India Standard Time getting printed.
I have the latest version of skyfield.
Metadata
Metadata
Assignees
Labels
No labels