As you would expect with a genealogical data format, dates form a
major part of information contained within it. Within
tidyged
there are a number of different date types that can
be defined, and there is a helper function for each type to ensure it is
formatted correctly.
Dates that occur on a specific defined date are defined using the
date_exact()
function:
Calendar dates are the most common type of date used. They can not
only be used to create specific dates like date_exact()
,
they underpin the other date types described below. They can be created
using the date_calendar()
function:
date_calendar(year = 1999, month = 4, day = 5)
#> [1] "5 APR 1999"
date_calendar(year = 1999, month = 4)
#> [1] "APR 1999"
date_calendar(year = 1999)
#> [1] "1999"
date_calendar(month = 4, day = 5)
#> [1] "5 APR"
English dates before 1752 were often given in dual format. This can
be achieved using the year_is_dual
parameter:
Years before the Common Era can be defined using the
year_is_bce
parameter:
Note that only the Gregorian calendar is currently supported.
Approximate dates (i.e. those expressing uncertainty) use the
qualifiers ‘about’, ‘calculated’, or ‘estimated’ in conjunction with a
date_calendar()
object:
date_calendar(year = 1999, month = 4, day = 5) |> date_approximated(about = TRUE)
#> [1] "ABT 5 APR 1999"
date_calendar(year = 1999, month = 4, day = 5) |> date_approximated(calc = TRUE)
#> [1] "CAL 5 APR 1999"
date_calendar(year = 1999, month = 4, day = 5) |> date_approximated(est = TRUE)
#> [1] "EST 5 APR 1999"
Date periods can take one or two date_calendar()
objects:
date_period(start_date = date_calendar(1956, 7, 26),
end_date = date_calendar(1956, 9, 15))
#> [1] "FROM 26 JUL 1956 TO 15 SEP 1956"
date_period(start_date = date_calendar(1956, 7, 26))
#> [1] "FROM 26 JUL 1956"
date_period(end_date = date_calendar(1956, 9, 15))
#> [1] "TO 15 SEP 1956"
Providing only one date gives a semi-infinite period.
Date ranges can be defined using date_range()
. Unlike
date_period()
, they describe when an event occurred rather
than a duration.
date_range(start_date = date_calendar(1956, 7, 26),
end_date = date_calendar(1956, 9, 15))
#> [1] "BET 26 JUL 1956 AND 15 SEP 1956"
date_range(start_date = date_calendar(1956, 7, 26))
#> [1] "AFT 26 JUL 1956"
date_range(end_date = date_calendar(1956, 9, 15))
#> [1] "BEF 15 SEP 1956"
It’s important to note that approximate dates cannot be used in date
ranges or date periods. The GEDCOM specification does allow arbitrary
“date phrases” enclosed in parentheses, but recommends these are added
as notes instead. The tidyged
package doesn’t allow you to
create date phrases (only as notes) but will accept them from imported
files.