That’s a weird rule of century inference in the year mask y
.
In the documentation we have the following information on the conversion of double-digit dates:
%y
Year without century (00-99). At the entrance, values between 00 and 68 are
prefixed by 20 and values between 69 and 99 by 19 - this is the behavior
specified by the POSIX 2004 and 2008 standards, but they [the authors of
standard] also say that "is
expected that in a future version the standard century inferred from a year of two
digits will change".
In this way, it is up to the application to manipulate the century according to its own rules, for example, you can fix which dates in the future should be converted to the 20th century:
data_de_nascimento = c("16/03/66", "11/06/87", "21/11/75", "05/09/70",
"15/08/70", "15/08/70")
d <- as.Date(data_de_nascimento, "%d/%m/%y" )
data_de_nascimento_format <- as.Date(
ifelse(d > Sys.Date(), format(d, "19%y-%m-%d"), format(d)))
You can replace Sys.Date()
by a specific cut-off date. For example, if you want feathers between 00 and 10 dates to be inferred for the 21st century use "2010-12-31"
. In that case, 16/03/10
will be interpreted as "2010-03-16"
, however 16/03/11
will be interpreted as "1911-03-16"
.
Reference: Soen - Add correct century to Dates with year provided as "Year without century", %y