Skip to content

Time Conversions

Functions for converting between different time systems and formats.

Time System Offset Functions

time_system_offset_for_mjd builtin

time_system_offset_for_mjd(mjd: float, time_system_src: TimeSystem, time_system_dst: TimeSystem) -> float

Calculate the offset between two time systems for a given Modified Julian Date.

Parameters:

Name Type Description Default
mjd float

Modified Julian date

required
time_system_src TimeSystem

Source time system

required
time_system_dst TimeSystem

Destination time system

required

Returns:

Name Type Description
float float

Offset between time systems in seconds

time_system_offset_for_jd builtin

time_system_offset_for_jd(jd: float, time_system_src: TimeSystem, time_system_dst: TimeSystem) -> float

Calculate the offset between two time systems for a given Julian Date.

Parameters:

Name Type Description Default
jd float

Julian date

required
time_system_src TimeSystem

Source time system

required
time_system_dst TimeSystem

Destination time system

required

Returns:

Name Type Description
float float

Offset between time systems in seconds

time_system_offset_for_datetime builtin

time_system_offset_for_datetime(year: int, month: int, day: int, hour: int, minute: int, second: float, nanosecond: float, time_system_src: TimeSystem, time_system_dst: TimeSystem) -> float

Calculate the offset between two time systems for a given Gregorian calendar date.

Parameters:

Name Type Description Default
year int

Year

required
month int

Month (1-12)

required
day int

Day of month (1-31)

required
hour int

Hour (0-23)

required
minute int

Minute (0-59)

required
second float

Second with fractional part

required
nanosecond float

Nanosecond component

required
time_system_src TimeSystem

Source time system

required
time_system_dst TimeSystem

Destination time system

required

Returns:

Name Type Description
float float

Offset between time systems in seconds

DateTime Conversion Functions

datetime_to_jd builtin

datetime_to_jd(year: int, month: int, day: int, hour: int, minute: int, second: float, nanosecond: float) -> float

Convert a Gregorian calendar date to the equivalent Julian Date.

Note: Due to the ambiguity of the nature of leap second insertion, this method should not be used if a specific behavior for leap second insertion is expected. This method treats leap seconds as if they don't exist.

Parameters:

Name Type Description Default
year int

Year

required
month int

Month (1-12)

required
day int

Day of month (1-31)

required
hour int

Hour (0-23)

required
minute int

Minute (0-59)

required
second float

Second with fractional part

required
nanosecond float

Nanosecond component

required

Returns:

Type Description
float

Julian date of epoch

datetime_to_mjd builtin

datetime_to_mjd(year: int, month: int, day: int, hour: int, minute: int, second: float, nanosecond: float) -> float

Convert a Gregorian calendar date to the equivalent Modified Julian Date.

Note: Due to the ambiguity of the nature of leap second insertion, this method should not be used if a specific behavior for leap second insertion is expected. This method treats leap seconds as if they don't exist.

Parameters:

Name Type Description Default
year int

Year

required
month int

Month (1-12)

required
day int

Day of month (1-31)

required
hour int

Hour (0-23)

required
minute int

Minute (0-59)

required
second float

Second with fractional part

required
nanosecond float

Nanosecond component

required

Returns:

Type Description
float

Modified Julian date of epoch

jd_to_datetime builtin

jd_to_datetime(jd: float) -> tuple

Convert a Julian Date to the equivalent Gregorian calendar date.

Note: Due to the ambiguity of the nature of leap second insertion, this method should not be used if a specific behavior for leap second insertion is expected. This method treats leap seconds as if they don't exist.

Parameters:

Name Type Description Default
jd float

Julian date

required

Returns:

Name Type Description
tuple tuple

A tuple containing (year, month, day, hour, minute, second, nanosecond)

mjd_to_datetime builtin

mjd_to_datetime(mjd: float) -> tuple

Convert a Modified Julian Date to the equivalent Gregorian calendar date.

Note: Due to the ambiguity of the nature of leap second insertion, this method should not be used if a specific behavior for leap second insertion is expected. This method treats leap seconds as if they don't exist.

Parameters:

Name Type Description Default
mjd float

Modified Julian date

required

Returns:

Name Type Description
tuple tuple

A tuple containing (year, month, day, hour, minute, second, nanosecond)