How best to represent *very* wide time ranges?

77 Views Asked by At

I'm wanting to write a program to store various events across all of history, from the big bang until the heat death of the universe.

Is there a standard way of representing this range of time? Most datetime libraries struggle with dates more than 5000 years in the future/past, so I don't think any existing libraries will work, except maybe as a default for "close enough" datetimes.

I'm happy if it's not exact, and if I can avoid it I won't consider the different calendars. Especially for events that occurred millions of years ago, I don't need millisecond precision.

I'll be writing this in Rust, but the implementation shouldn't change too much from one language to the next.

My first thought would be to wrap a datetime library with my own struct that defines some 64-bit integers for the greater time ranges:

struct BigTime {
    datetime: <library's datetime object>,
    millions_of_years: i64,
    trillions_of_years: i64,
}

Is there a "neater" way of doing this?

0

There are 0 best solutions below