r-lib / clock

A Date-Time Library for R
https://clock.r-lib.org
Other
97 stars 4 forks source link

Consider how hard it would be to allow `Inf` / `-Inf` #317

Open DavisVaughan opened 1 year ago

DavisVaughan commented 1 year ago

For time points, could follow the duckdb approach of using INT64_MAX/MIN as special infinity values https://github.com/duckdb/duckdb/blob/8edeaf41a6a683d9df84d609a4f7660ef5f8d8d9/src/include/duckdb/common/types/timestamp.hpp#L79-L88

For calendars, could define that if year = max_year + 1, then that is considered infinity? Similar with negative infinity. This could possibly work because the max year is defined to be 32767 due to the use of a short for year, but we store our year in an int due to having to be compatible with R. Since all calendar types have a year field, 32767 + 1 could be infinity?

After figuring out how the storage would work, then it would be a matter of fixing the print method and adding special support everywhere to ensure propagation is working as expected. Not easy!