Skip to content

Time Range

The TimeRange class provides an easy way to iterate over a range of time instances. You can specify a start and end Epoch, along with a time step in seconds, and the TimeRange will generate all the Epoch instances within that range at the specified intervals.

import brahe as bh

bh.initialize_eop()

for epc in bh.TimeRange(
    bh.Epoch(2024, 1, 1, 0, 0, 0.0, time_system=bh.UTC),
    bh.Epoch(2024, 1, 2, 0, 0, 0.0, time_system=bh.UTC),
    3600.0,
):
    print(epc)
use brahe as bh;

fn main() {
    bh::initialize_eop().unwrap();

    for epc in bh::TimeRange::new(
        bh::Epoch::from_datetime(2024, 1, 1, 0, 0, 0.0, 0.0, bh::TimeSystem::UTC),
        bh::Epoch::from_datetime(2024, 1, 2, 0, 0, 0.0, 0.0, bh::TimeSystem::UTC),
        3600.0
    ) {
        println!("{}", epc);
    }
}
Output
2024-01-01 00:00:00.000 UTC
2024-01-01 01:00:00.000 UTC
2024-01-01 02:00:00.000 UTC
2024-01-01 03:00:00.000 UTC
2024-01-01 04:00:00.000 UTC
2024-01-01 05:00:00.000 UTC
2024-01-01 06:00:00.000 UTC
2024-01-01 07:00:00.000 UTC
2024-01-01 08:00:00.000 UTC
2024-01-01 09:00:00.000 UTC
2024-01-01 10:00:00.000 UTC
2024-01-01 11:00:00.000 UTC
2024-01-01 12:00:00.000 UTC
2024-01-01 13:00:00.000 UTC
2024-01-01 14:00:00.000 UTC
2024-01-01 15:00:00.000 UTC
2024-01-01 16:00:00.000 UTC
2024-01-01 17:00:00.000 UTC
2024-01-01 18:00:00.000 UTC
2024-01-01 19:00:00.000 UTC
2024-01-01 20:00:00.000 UTC
2024-01-01 21:00:00.000 UTC
2024-01-01 22:00:00.000 UTC
2024-01-01 23:00:00.000 UTC
2024-01-01 00:00:00.000 UTC
2024-01-01 01:00:00.000 UTC
2024-01-01 02:00:00.000 UTC
2024-01-01 03:00:00.000 UTC
2024-01-01 04:00:00.000 UTC
2024-01-01 05:00:00.000 UTC
2024-01-01 06:00:00.000 UTC
2024-01-01 07:00:00.000 UTC
2024-01-01 08:00:00.000 UTC
2024-01-01 09:00:00.000 UTC
2024-01-01 10:00:00.000 UTC
2024-01-01 11:00:00.000 UTC
2024-01-01 12:00:00.000 UTC
2024-01-01 13:00:00.000 UTC
2024-01-01 14:00:00.000 UTC
2024-01-01 15:00:00.000 UTC
2024-01-01 16:00:00.000 UTC
2024-01-01 17:00:00.000 UTC
2024-01-01 18:00:00.000 UTC
2024-01-01 19:00:00.000 UTC
2024-01-01 20:00:00.000 UTC
2024-01-01 21:00:00.000 UTC
2024-01-01 22:00:00.000 UTC
2024-01-01 23:00:00.000 UTC