joeroe/era

Year zero problem

joeroe opened this issue · 2 comments

When converting between CE-based and BP-based eras, yr_transform() does not account for the absence of a year zero.

library("era")
yr_transform(yr(10000, "BP"), era("BCE"))
#> # BCE years <yr[1]>:
#> [1] 8051
#> # Era: Before Common Era (BCE): calendar years, counted backwards from 1

OxCal is good at this kind of thing.

This is still a problem, e.g.:

a <- yr(10, "BC")
b <- yr(10, "CE")
b - yr_transform(a, "CE")
#> # CE years <yr[1]>:
#> [1] 20
#> # Era: Common Era (CE): Gregorian years (365.2425 days), counted forwards from 0

Redefining era epochs using an epoch that has a year 0 (e.g. b2k) might help?

Redefining epochs in a system without a year 0 is a good solution, but b2k introduces the complication of it now being counted backwards instead of forwards. So instead we'll stick with Gregorian years, but using astronomical numbering, i.e. there is a year zero.

This means the epoch of CE is now 0 (i.e. the start of 1 CE was one year after the start of 0 CE) and the epoch of BCE is now 1 (i.e. the start of 1 BCE was one year before the start of 1 CE). Definitions of epochs derived from a (fractional) CE year, e.g. Hijri years, also had to be adjusted.

This seems to make things consistent across the board. I've also added a test to try and catch these annoying off-by-one issues in era definition in future.