pad leading zero to BC year in R

Viewed 34

I am converting a negative numeric to a BC date using the Lubridate package, I want to add the initial 0 to three or two digits year. Here is an example:

library(lubridate)
lubridate::as_date(-836404) #note that the number is negative for BC

result gives

"-320-01-02"

But I want it to give

"-0320-01-02"

I want to keep it as a date. Any suggestion?

0 Answers
Related