| Title: | Calendrical Calculations |
|---|---|
| Description: | An R implementation of the algorithms described in Reingold and Dershowitz (4th ed., Cambridge University Press, 2018) <doi:10.1017/9781107415058>, allowing conversion between many different calendar systems. Cultural and religious holidays from several calendars can be calculated. |
| Authors: | Rob Hyndman [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-2140-5352>), Edward Reingold [cph, ctb] (Original Lisp code), Nachum Dershowitz [cph, ctb] (Original Lisp code) |
| Maintainer: | Rob Hyndman <[email protected]> |
| License: | Apache License (>= 2) |
| Version: | 1.0.4.9000 |
| Built: | 2026-06-03 11:30:47 UTC |
| Source: | https://github.com/robjhyndman/calcal |
Functions to return Gregorian dates for various Christian ecclesiastical holidays and other special days
Coptic Christmas is celebrated on 29th of Koiak in the Coptic calendar, which currently corresponds to 7 or 8 January in the Gregorian calendar.
advent(year) christmas(year) orthodox_christmas(year) epiphany(year) easter(year) orthodox_easter(year) pentecost(year) coptic_christmas(year) astronomical_easter(year)advent(year) christmas(year) orthodox_christmas(year) epiphany(year) easter(year) orthodox_easter(year) pentecost(year) coptic_christmas(year) astronomical_easter(year)
year |
Gregorian year |
A vector of dates on the Gregorian calendar
tibble::tibble( year = 2025:2030, advent = advent(year), christmas = christmas(year), orthodox_christmas = orthodox_christmas(year), epiphany = epiphany(year), easter = easter(year), orthodox_easter = orthodox_easter(year), pentecost = pentecost(year) )tibble::tibble( year = 2025:2030, advent = advent(year), christmas = christmas(year), orthodox_christmas = orthodox_christmas(year), epiphany = epiphany(year), easter = easter(year), orthodox_easter = orthodox_easter(year), pentecost = pentecost(year) )
New dates can be calculated using new_date() for any calendar. Dates can be
converted from one calendar to another using as_date(). as_date() also works
with the native R Date class and several other classes. When applied to
integers, the conversion is from the RD day number (with day 1 being
01-01-01 on the Gregorian calendar).
as_date(date, calendar) new_date(..., calendar)as_date(date, calendar) new_date(..., calendar)
date |
Date vector on some calendar |
calendar |
Target calendar of class "calendar" |
... |
Named arguments denoting the granularities required for |
A date vector of class "rdvec" with the specified calendar.
april2025 <- new_date(year = 2025, month = 4, day = 1:30, calendar = cal_gregorian) as_date(april2025, calendar = cal_iso)april2025 <- new_date(year = 2025, month = 4, day = 1:30, calendar = cal_gregorian) as_date(april2025, calendar = cal_iso)
Convert to time of day
as_time_of_day(x, ...)as_time_of_day(x, ...)
x |
Vector of times |
... |
Additional arguments not currently used |
A vector containing "time_of_day" objects
as_time_of_day(Sys.time())as_time_of_day(Sys.time())
The classical Babylonian calendar was a lunisolar calendar with a fixed 19-year Metonic cycle.
babylonian_date( year = integer(), month = integer(), leap_month = logical(), day = integer() ) as_babylonian(date)babylonian_date( year = integer(), month = integer(), leap_month = logical(), day = integer() ) as_babylonian(date)
year |
Numeric vector of years |
month |
Numeric vector of months |
leap_month |
Logical vector of leap months |
day |
Numeric vector of days |
date |
Vector of dates on some calendar. |
A babylonian vector object
## Not run: tibble::tibble( gregorian = gregorian_date(2335, 1, 1:2), babylonian = as_babylonian(gregorian) ) babylonian_date(2335, 6, FALSE, 1:2) ## End(Not run)## Not run: tibble::tibble( gregorian = gregorian_date(2335, 1, 1:2), babylonian = as_babylonian(gregorian) ) babylonian_date(2335, 6, FALSE, 1:2) ## End(Not run)
The Bahá'í calendar is a solar calendar used in the Bahá'í faith comprising 18 months, with four or five intercalary days each year. The New Year is at the northern Spring equinox, corresponding to 21 March on the Gregorian calendar. Ayyám-i-Há is specified as month 20.
bahai_date( major = integer(), cycle = integer(), year = integer(), month = integer(), day = integer() ) as_bahai(date)bahai_date( major = integer(), cycle = integer(), year = integer(), month = integer(), day = integer() ) as_bahai(date)
major |
A numeric vector of major periods |
cycle |
A numeric vector of cycles |
year |
A numeric vector of years within the cycles |
month |
A numeric vector of months |
day |
A numeric vector of days |
date |
A numeric vector of dates |
A bahai vector object
tibble::tibble( gregorian = gregorian_date(2025, 2, 15) + 0:30, bahai = as_bahai(gregorian) ) bahai_date(1, 10, 11, 3, 5:7)tibble::tibble( gregorian = gregorian_date(2025, 2, 15) + 0:30, bahai = as_bahai(gregorian) ) bahai_date(1, 10, 11, 3, 5:7)
Dates are returned as Gregorian dates
bahai_new_year(year) naw_ruz(year) feast_of_ridvan(year) birth_of_the_bab(year)bahai_new_year(year) naw_ruz(year) feast_of_ridvan(year) birth_of_the_bab(year)
year |
The year on the Gregorian calendar |
A vector of dates on the Gregorian calendar
tibble::tibble( year = 2025:2030, new_year = bahai_new_year(year), naw_ruz = naw_ruz(year), ridvan = feast_of_ridvan(year), birth_bab = birth_of_the_bab(year) )tibble::tibble( year = 2025:2030, new_year = bahai_new_year(year), naw_ruz = naw_ruz(year), ridvan = feast_of_ridvan(year), birth_bab = birth_of_the_bab(year) )
The Balinese calendar repeats every 210 days. It has 10 concurrent weeks, of lengths 1, 2, ..., 10 days. The 210 day cycles are unnumbered, so there is no way to convert a Balinese date into a unique date on another calendar.
balinese_date( luang = integer(), dwiwara = integer(), triwara = integer(), caturwara = integer(), pancawara = integer(), sadwara = integer(), saptawara = integer(), asatawara = integer(), sangawara = integer(), dasawara = integer() ) as_balinese(date)balinese_date( luang = integer(), dwiwara = integer(), triwara = integer(), caturwara = integer(), pancawara = integer(), sadwara = integer(), saptawara = integer(), asatawara = integer(), sangawara = integer(), dasawara = integer() ) as_balinese(date)
luang |
A numeric vector |
dwiwara |
A numeric vector |
triwara |
A numeric vector |
caturwara |
A numeric vector |
pancawara |
A numeric vector |
sadwara |
A numeric vector |
saptawara |
A numeric vector |
asatawara |
A numeric vector |
sangawara |
A numeric vector |
dasawara |
A numeric vector |
date |
A vector of dates on some calendar. |
A balinese vector object
gregorian_date(2025, 6, 1:10) |> as_balinese()gregorian_date(2025, 6, 1:10) |> as_balinese()
The traditional Chinese lunisolar calendar uses a 60-year cycle with 12 months per year. The Japanese, Korean and Vietnamese calendars are almost identical, but with different locations for determining astronomical positions.
chinese_date( cycle = integer(), year = integer(), month = integer(), leap_month = logical(), day = integer() ) japanese_date( cycle = integer(), year = integer(), month = integer(), leap_month = logical(), day = integer() ) korean_date( year = integer(), month = integer(), leap_month = logical(), day = integer() ) vietnamese_date( cycle = integer(), year = integer(), month = integer(), leap_month = logical(), day = integer() ) as_chinese(date) as_japanese(date) as_korean(date) as_vietnamese(date)chinese_date( cycle = integer(), year = integer(), month = integer(), leap_month = logical(), day = integer() ) japanese_date( cycle = integer(), year = integer(), month = integer(), leap_month = logical(), day = integer() ) korean_date( year = integer(), month = integer(), leap_month = logical(), day = integer() ) vietnamese_date( cycle = integer(), year = integer(), month = integer(), leap_month = logical(), day = integer() ) as_chinese(date) as_japanese(date) as_korean(date) as_vietnamese(date)
cycle |
A numeric vector of cycles |
year |
A numeric vector of years within the cycles |
month |
A numeric vector of months |
leap_month |
A logical vector indicating leap months |
day |
A numeric vector of days |
date |
A numeric vector of dates |
A chinese vector object
chinese <- new_date( cycle = 78, year = 42, month = 5, leap_month = FALSE, day = 16:18, calendar = cal_chinese ) chinese chinese_date(78, 42, 5, FALSE, 16:18) as_date(chinese, calendar = cal_gregorian) as_date(Sys.Date(), calendar = cal_chinese) tibble::tibble( gregorian = gregorian_date(2025, 1, 1) + 0:364, chinese = as_chinese(gregorian) ) as_gregorian(chinese_date(78, 41, 12, FALSE, 3:30)) as_chinese(gregorian_date(2025, 1, 1:28)) as_chinese("2016-01-01") as_chinese(Sys.Date())chinese <- new_date( cycle = 78, year = 42, month = 5, leap_month = FALSE, day = 16:18, calendar = cal_chinese ) chinese chinese_date(78, 42, 5, FALSE, 16:18) as_date(chinese, calendar = cal_gregorian) as_date(Sys.Date(), calendar = cal_chinese) tibble::tibble( gregorian = gregorian_date(2025, 1, 1) + 0:364, chinese = as_chinese(gregorian) ) as_gregorian(chinese_date(78, 41, 12, FALSE, 3:30)) as_chinese(gregorian_date(2025, 1, 1:28)) as_chinese("2016-01-01") as_chinese(Sys.Date())
Dates are returned as Gregorian dates
chinese_new_year(year) dragon_festival(year) qing_ming(year)chinese_new_year(year) dragon_festival(year) qing_ming(year)
year |
The year on the Gregorian calendar |
A vector of dates on the Gregorian calendar
tibble::tibble( year = 2025:2030, cny = chinese_new_year(year), qm = qing_ming(year), dbf = dragon_festival(year) )tibble::tibble( year = 2025:2030, cny = chinese_new_year(year), qm = qing_ming(year), dbf = dragon_festival(year) )
These two calendars are identical apart from the starting point or epoch. The Coptic calendar (also called the Alexandrian calendar) starts on 29 August 284 CE in the Julian calendar, while the Ethiopic (or Ethiopian) calendar starts on 29 August 8 CE in the Julian calendar. The Coptic calendar is used by the Coptic Orthodox and Coptic Catholic Churches, while the Ethiopic calendar is the official state calendar of Ethiopia, and unofficial calendar of Eritrea, and is used by the Ethiopian and Eritrean Orthodox Churches. Both calendars have 13 months, with 12 months of 30 days and a 13th month of 5 or 6 days depending on whether it is a leap year. Leap years occur every 4 years.
coptic_date(year = integer(), month = integer(), day = integer()) ethiopic_date(year = integer(), month = integer(), day = integer()) as_coptic(date) as_ethiopic(date)coptic_date(year = integer(), month = integer(), day = integer()) ethiopic_date(year = integer(), month = integer(), day = integer()) as_coptic(date) as_ethiopic(date)
year |
A numeric vector of years |
month |
A numeric vector of months |
day |
A numeric vector of days |
date |
A numeric vector of dates |
A coptic or ethiopic vector object
cal_coptic, cal_ethiopic, coptic_christmas
tibble::tibble( gregorian = gregorian_date(2025, 1, 1:31), coptic = as_coptic(gregorian), ethiopic = as_ethiopic(gregorian) ) coptic_date(1741, 5, 16:18) as_date(Sys.Date(), calendar = cal_ethiopic) as_coptic("2016-01-01") as_ethiopic(Sys.Date())tibble::tibble( gregorian = gregorian_date(2025, 1, 1:31), coptic = as_coptic(gregorian), ethiopic = as_ethiopic(gregorian) ) coptic_date(1741, 5, 16:18) as_date(Sys.Date(), calendar = cal_ethiopic) as_coptic("2016-01-01") as_ethiopic(Sys.Date())
Compute days, weeks, or months from a vector of dates. These work for Gregorian
dates, and for some other calendars where it makes sense. In particular, day_of_week
has been implemented for many calendars that contain the concept of a week. Similarly,
day_of_month, day_of_year and days_remaining will work for several calendars.
day_of_week(date, ...) day_of_month(date) day_of_year(date) days_remaining(date) week_of_month(date, first_day = "Monday") week_of_year(date, first_day = "Monday") month_of_year(date) year(date)day_of_week(date, ...) day_of_month(date) day_of_year(date) days_remaining(date) week_of_month(date, first_day = "Monday") week_of_year(date, first_day = "Monday") month_of_year(date) year(date)
date |
A vector of dates |
... |
Other arguments used for specific calendars |
first_day |
Character denoting first day of the week. Default is |
week_of_year() returns the ISO 8601 week number with first_day as Monday.
Under this standard, week 1 of a year is defined as the first week with at least 4 days in the year;
equivalently, it is the week containing 4 January. There is no week 0; instead week 1 of a year may
begin in the previous calendar year.
week_of_month() is defined analogously where week 1 of a month is the first week with at least
4 days in the month; equivalently, it is the week containing the 4th day of the month. There is no week 0;
instead week 1 of a month may begin in the previous calendar month.
days_remaining() returns the number of days remaining in the year.
Other functions should be self-explanatory.
A vector of numerical values for the requested granularity. In the case of day_of_week(), it returns a character vector of the name of the day of the week, or a numeric vector if numeric = TRUE is specified.
april2025 <- gregorian_date(2025, 4, 1:30) day_of_week(april2025) day_of_month(april2025) day_of_year(april2025) days_remaining(april2025) week_of_month(april2025) week_of_year(april2025) month_of_year(april2025)april2025 <- gregorian_date(2025, 4, 1:30) day_of_week(april2025) day_of_month(april2025) day_of_year(april2025) days_remaining(april2025) week_of_month(april2025) week_of_year(april2025) month_of_year(april2025)
The ancient Egyptian calendar is a 365-day solar calendar with 12 months of 30 days each, plus a 13th month of 5 days. The Armenian calendar is similar but has a different epoch and month names.
egyptian_date(year = integer(), month = integer(), day = integer()) armenian_date(year = integer(), month = integer(), day = integer()) as_egyptian(date) as_armenian(date)egyptian_date(year = integer(), month = integer(), day = integer()) armenian_date(year = integer(), month = integer(), day = integer()) as_egyptian(date) as_armenian(date)
year |
Numeric vector of years |
month |
Numeric vector of months |
day |
Numeric vector of days |
date |
Vector of dates on some calendar |
An egyptian or armenian vector object
tibble::tibble( gregorian = gregorian_date(2025, 5, 1:10), egyptian = as_egyptian(gregorian), armenian = as_armenian(gregorian) )tibble::tibble( gregorian = gregorian_date(2025, 5, 1:10), egyptian = as_egyptian(gregorian), armenian = as_armenian(gregorian) )
There are two versions of the French Revolutionary Calendar. The original version, used from 1793, was kept in sync with the solar year by setting the first day of Vendemiaire to the autumnal equinox. The second version, proposed in 1795, was a simpler arithmetic calendar, but was never used. We distinguish the two by using "afrench" (for Arithmetic French) for the second form.
french_date(year = integer(), month = integer(), day = integer()) afrench_date(year = integer(), month = integer(), day = integer()) as_french(date) as_afrench(date)french_date(year = integer(), month = integer(), day = integer()) afrench_date(year = integer(), month = integer(), day = integer()) as_french(date) as_afrench(date)
year |
year |
month |
month |
day |
day |
date |
A vector of dates on some calendar |
A vector of dates on the French Revolutionary calendar
french_date(1, 1, 1:15) |> as_gregorian() french_date(1, 1, 1:15) |> day_of_week()french_date(1, 1, 1:15) |> as_gregorian() french_date(1, 1, 1:15) |> day_of_week()
granularities() will return a character vector of canonical granularity names for the
relevant calendar. These are the granularities used to define dates on the calendar.
granularity() will return a vector of numerical values for a given canonical granularity.
granularity_names(calendar) granularity(date, granularity)granularity_names(calendar) granularity(date, granularity)
calendar |
An object defining a calendar, of "calendar" class. |
date |
A date vector on some calendar |
granularity |
A character string indicating the granularity to extract |
A character vector of granularity names or a vector of numerical values for the specified granularity.
week_of_year for some non-canonical granularities.
granularity_names(cal_iso) granularity_names(cal_gregorian) date_iso <- new_date(year = 2025, week = 23, day = 2, calendar = cal_iso) granularity(date_iso, "week") date_gregorian <- new_date(year = 2025, month = 1, day = 1, calendar = cal_gregorian) granularity(date_gregorian, "month")granularity_names(cal_iso) granularity_names(cal_gregorian) date_iso <- new_date(year = 2025, week = 23, day = 2, calendar = cal_iso) granularity(date_iso, "week") date_gregorian <- new_date(year = 2025, month = 1, day = 1, calendar = cal_gregorian) granularity(date_gregorian, "month")
The Gregorian calendar is the standard calendar used by most of the world. It was named for Pope Gregory XIII who introduced it in 1582. It is a modification of the Julian calendar which was in use at the time.
gregorian_date(year = integer(), month = integer(), day = integer()) as_gregorian(date)gregorian_date(year = integer(), month = integer(), day = integer()) as_gregorian(date)
year |
A numeric vector of years |
month |
A numeric vector of months |
day |
A numeric vector of days |
date |
Vector of dates on some calendar |
A gregorian vector object
new_date(year = 2025, month = 3, day = 2:4, calendar = cal_gregorian) gregorian_date(2025, 4, 19:30) as_date(Sys.Date(), calendar = cal_gregorian) as_gregorian(Sys.Date()) as_gregorian("2016-01-01") tibble::tibble( x = seq(as.Date("2025-01-01"), as.Date("2025-12-31"), by = "day"), y = as_gregorian(x), z = as_date(x, calendar = cal_gregorian) )new_date(year = 2025, month = 3, day = 2:4, calendar = cal_gregorian) gregorian_date(2025, 4, 19:30) as_date(Sys.Date(), calendar = cal_gregorian) as_gregorian(Sys.Date()) as_gregorian("2016-01-01") tibble::tibble( x = seq(as.Date("2025-01-01"), as.Date("2025-12-31"), by = "day"), y = as_gregorian(x), z = as_date(x, calendar = cal_gregorian) )
The Hebrew (or Jewish) calendar is an official calendar of Israel, and is used for Jewish religious holidays. It is a lunisolar calendar comprising months of 29 or 30 days, which begin and end at approximately the time of the new moon. An extra lunar month is added every 2 or 3 years, so the calendar has either 12 or 13 months per year.
hebrew_date(year = integer(), month = integer(), day = integer()) as_hebrew(date) ohebrew_date(year = integer(), month = integer(), day = integer()) as_ohebrew(date) samaritan_date(year = integer(), month = integer(), day = integer()) as_samaritan(date)hebrew_date(year = integer(), month = integer(), day = integer()) as_hebrew(date) ohebrew_date(year = integer(), month = integer(), day = integer()) as_ohebrew(date) samaritan_date(year = integer(), month = integer(), day = integer()) as_samaritan(date)
year |
A numeric vector of years |
month |
A numeric vector of months |
day |
A numeric vector of days |
date |
Vector of dates on some calendar |
The observational Hebrew calendar ("ohebrew") is the classical calendar where the new month began with the reported observation of the crescent new moon. In this implementation, Haifa is taken as the point of observation.
The Samaritan calendar is similar, but the moment of new moon marking the start of each new month is based on a traditional reckoning of the lunar cycle,
A hebrew vector object
heb <- new_date(year = 5785, month = 3, day = 2:4, calendar = cal_hebrew) heb hebrew_date(5785, 3, 2:4) as_date(heb, calendar = cal_gregorian) as_date(Sys.Date(), calendar = cal_hebrew) tibble::tibble( gregorian = gregorian_date(2025, 1, 1) + 0:364, hebrew = as_date(gregorian, calendar = cal_hebrew), ) as_gregorian(hebrew_date(5785, 3, 2:4)) as_hebrew(gregorian_date(2025, 1, 1:31)) as_hebrew("2016-01-01") as_hebrew(Sys.Date()) hebrew_date(5785, 3, 1:10) |> day_of_week()heb <- new_date(year = 5785, month = 3, day = 2:4, calendar = cal_hebrew) heb hebrew_date(5785, 3, 2:4) as_date(heb, calendar = cal_gregorian) as_date(Sys.Date(), calendar = cal_hebrew) tibble::tibble( gregorian = gregorian_date(2025, 1, 1) + 0:364, hebrew = as_date(gregorian, calendar = cal_hebrew), ) as_gregorian(hebrew_date(5785, 3, 2:4)) as_hebrew(gregorian_date(2025, 1, 1:31)) as_hebrew("2016-01-01") as_hebrew(Sys.Date()) hebrew_date(5785, 3, 1:10) |> day_of_week()
Functions to return Gregorian dates for various Hindu holidays based on the Hindu calendars. Hindu Lunar New Year is the first day of the lunar month of Caitra (month 1). The Birthday of Rama is on the 8th or 9th day of the first month (Caitra). Diwali is on the new moon day in the month of Kartik (month 8). The Great Night of Shiva is at the end of the 11 month of Magha. Mesha Sankranti is the day when the sun enters the sign of Aries (Mesha). Sacred Wednesdays are the 8th day of the lunar month that falls on a Wednesday. Dates may vary by a day or two due to variations of the lunar calendar and local traditions.
hindu_lunar_new_year(year) mesha_sankranti(year) diwali(year) shiva(year) rama(year) sacred_wednesdays(year)hindu_lunar_new_year(year) mesha_sankranti(year) diwali(year) shiva(year) rama(year) sacred_wednesdays(year)
year |
A numeric vector of Gregorian years |
A vector of dates on the Gregorian calendar
shiva(2025:2026) hindu_lunar_new_year(2025:2026) rama(2025:2026) mesha_sankranti(2025:2026) diwali(2025:2026) sacred_wednesdays(2025:2026)shiva(2025:2026) hindu_lunar_new_year(2025:2026) rama(2025:2026) mesha_sankranti(2025:2026) diwali(2025:2026) sacred_wednesdays(2025:2026)
There are four Hindu calendars implemented: modern Hindu solar and lunar calendars, and the old Hindu solar and lunar calendars. Hindu solar months are 1/12 of a solar year (approximately 30.44 days), while lunar months are based on the lunar cycle (approximately 29.53 days).
hindu_solar_date(year, month, day) hindu_lunar_date(year, month, leap_month, day, leap_day) as_hindu_solar(date) as_hindu_lunar(date) old_hindu_solar_date(year = integer(), month = integer(), day = integer()) old_hindu_lunar_date( year = integer(), month = integer(), leap_month = logical(), day = integer() ) as_old_hindu_solar(date) as_old_hindu_lunar(date)hindu_solar_date(year, month, day) hindu_lunar_date(year, month, leap_month, day, leap_day) as_hindu_solar(date) as_hindu_lunar(date) old_hindu_solar_date(year = integer(), month = integer(), day = integer()) old_hindu_lunar_date( year = integer(), month = integer(), leap_month = logical(), day = integer() ) as_old_hindu_solar(date) as_old_hindu_lunar(date)
year |
A numeric vector of years |
month |
A numeric vector of months |
day |
A numeric vector of days |
leap_month |
A logical vector indicating if year is a leap year |
leap_day |
A logical vector indicating if day is a leap day |
date |
A date vector on some calendar |
A vector object of Hindu dates.
cal_hindu_solar, cal_hindu_lunar, cal_old_hindu_solar, cal_old_hindu_lunar, diwali
gregorian_date(2025, 1, 1:31) |> as_hindu_solar() gregorian_date(2025, 1, 1:31) |> as_hindu_lunar()gregorian_date(2025, 1, 1:31) |> as_hindu_solar() gregorian_date(2025, 1, 1:31) |> as_hindu_lunar()
The Icelandic calendar, still in use in Iceland, divides times into 7-day weeks and two seasons: Summer and Winter. Summer starts on the first Thursday after April 18th, and Winter 180 days earlier. Ordinary years have 52 weeks with leap years having 53 weeks. The leap week occurs every 5-7 years in midsummer.
icelandic_date( year = integer(), season = integer(), week = integer(), weekday = integer() ) as_icelandic(date)icelandic_date( year = integer(), season = integer(), week = integer(), weekday = integer() ) as_icelandic(date)
year |
A numeric vector of years |
season |
A numeric vector of seasons (1 = Summer, 2 = Winter) |
week |
A numeric vector of weeks within the season (1 to 28) |
weekday |
A number vector containing day of week (0 = Sunday, 1 = Monday, ..., 6 = Saturday)) |
date |
A numeric vector of dates |
An icelandic vector object
gregorian_date(2025, 4, 20:30) |> as_icelandic() icelandic_date(2025, 1, 6, 0:6) |> day_of_week()gregorian_date(2025, 4, 20:30) |> as_icelandic() icelandic_date(2025, 1, 6, 0:6) |> day_of_week()
The Islamic (or Hijri) calendar is a lunar calendar comprising 12 lunar months in a year of 354 or 355 days. It is widely used in for Islamic holidays, and in countries where the predominant religion is Islam.
islamic_date(year = integer(), month = integer(), day = integer()) as_islamic(date) oislamic_date(year = integer(), month = integer(), day = integer()) as_oislamic(date) saudi_date(year = integer(), month = integer(), day = integer()) as_saudi(date)islamic_date(year = integer(), month = integer(), day = integer()) as_islamic(date) oislamic_date(year = integer(), month = integer(), day = integer()) as_oislamic(date) saudi_date(year = integer(), month = integer(), day = integer()) as_saudi(date)
year |
A numeric vector of years |
month |
A numeric vector of months |
day |
A numeric vector of days |
date |
Vector of dates on some calendar |
Three variations are implemented here. The standard Islamic calendar
is available using as_islamic and islamic_date. The Saudi Islamic calendar
uses as_saudi and saudi_date, while the traditional observational
Islamic calendar is available using as_oislamic and oislamic_date.
An islamic vector object
islamic_date(2025, 5, 1:30) as_islamic("2016-01-01") as_islamic(Sys.Date()) tibble::tibble( x = seq(as.Date("2025-01-01"), as.Date("2025-12-31"), by = "day"), y = as_islamic(x) ) islamic_date(2025, 5, 1:10) |> day_of_week() islamic_date(2025, 4, 19:30)islamic_date(2025, 5, 1:30) as_islamic("2016-01-01") as_islamic(Sys.Date()) tibble::tibble( x = seq(as.Date("2025-01-01"), as.Date("2025-12-31"), by = "day"), y = as_islamic(x) ) islamic_date(2025, 5, 1:10) |> day_of_week() islamic_date(2025, 4, 19:30)
Functions to return Gregorian dates for various Islamic holidays. Specific dates can vary slightly based on moon sightings in different regions.
islamic_new_year(year) mawlid(year) ramadan(year) eid_al_fitr(year) eid_al_adha(year)islamic_new_year(year) mawlid(year) ramadan(year) eid_al_fitr(year) eid_al_adha(year)
year |
A numeric vector of Gregorian years |
A vector of dates on the Gregorian calendar
tibble::tibble( year = 2025:2029, `New year` = islamic_new_year(year), Mawlid = mawlid(year), Ramadan = ramadan(year), `Eid al-Fitr` = eid_al_fitr(year), `Eid al-Adha` = eid_al_adha(year) ) ramadan(2030)tibble::tibble( year = 2025:2029, `New year` = islamic_new_year(year), Mawlid = mawlid(year), Ramadan = ramadan(year), `Eid al-Fitr` = eid_al_fitr(year), `Eid al-Adha` = eid_al_adha(year) ) ramadan(2030)
In ISO 8601 date objects, weeks are defined as starting on Mondays. Week 1 is the first week with at least 4 days in the year. Equivalently, it is the week containing 4 January. There is no week 0; instead week 1 of a year may begin in the previous calendar year.
iso_date(year = integer(), week = integer(), day = integer()) as_iso(date)iso_date(year = integer(), week = integer(), day = integer()) as_iso(date)
year |
A numeric vector of years |
week |
A numeric vector of weeks |
day |
A numeric vector of days |
date |
Vector of dates on some calendar |
More flexible week numbering is possible using Gregorian dates with week_of_year().
An iso vector object
iso <- new_date(year = 2025, week = 23, day = 2:4, calendar = cal_iso) iso iso_date(2025, 23, 2:4) as_gregorian(iso_date(2025, 23, 2:4)) as_iso(gregorian_date(2025, 1, 1:31)) as_iso("2016-01-01") as_iso(Sys.Date()) tibble::tibble( x = seq(as.Date("2025-01-01"), as.Date("2025-12-31"), by = "day"), y = as_iso(x) )iso <- new_date(year = 2025, week = 23, day = 2:4, calendar = cal_iso) iso iso_date(2025, 23, 2:4) as_gregorian(iso_date(2025, 23, 2:4)) as_iso(gregorian_date(2025, 1, 1:31)) as_iso("2016-01-01") as_iso(Sys.Date()) tibble::tibble( x = seq(as.Date("2025-01-01"), as.Date("2025-12-31"), by = "day"), y = as_iso(x) )
The Julian calendar is the calendar used by the Roman Empire, and takes its name from Julius Caesar, who introduced it in 46 BC. It is still used as a religious calendar in parts of the Eastern Orthodox Church.
julian_date(year = integer(), month = integer(), day = integer()) as_julian(date)julian_date(year = integer(), month = integer(), day = integer()) as_julian(date)
year |
A numeric vector of years |
month |
A numeric vector of months |
day |
A numeric vector of days |
date |
Vector of dates on some calendar |
A julian vector object
as_date("2016-01-01", calendar = cal_julian) as_date(Sys.Date(), calendar = cal_julian) tibble::tibble( x = seq(as.Date("2025-01-01"), as.Date("2025-12-31"), by = "day"), y = as_date(x, calendar = cal_gregorian), z = as_date(x, calendar = cal_julian) ) new_date(year = 2025, month = 4, day = 19:30, calendar = cal_julian) julian_date(2025, 4, 19:30) as_julian("2016-01-01") as_julian(Sys.Date()) tibble::tibble( x = seq(as.Date("2025-01-01"), as.Date("2025-12-31"), by = "day"), y = as_julian(x) )as_date("2016-01-01", calendar = cal_julian) as_date(Sys.Date(), calendar = cal_julian) tibble::tibble( x = seq(as.Date("2025-01-01"), as.Date("2025-12-31"), by = "day"), y = as_date(x, calendar = cal_gregorian), z = as_date(x, calendar = cal_julian) ) new_date(year = 2025, month = 4, day = 19:30, calendar = cal_julian) julian_date(2025, 4, 19:30) as_julian("2016-01-01") as_julian(Sys.Date()) tibble::tibble( x = seq(as.Date("2025-01-01"), as.Date("2025-12-31"), by = "day"), y = as_julian(x) )
Find all occurrences of Kajeng Keliwon and Tumpek in a vector of Gregorian years.
kajeng_keliwon(year) tumpek(year)kajeng_keliwon(year) tumpek(year)
year |
A numeric vector of Gregorian years |
A vector of dates on the Gregorian calendar
kajeng_keliwon(2025) tumpek(2025)kajeng_keliwon(2025) tumpek(2025)
Create a location object. These are used for calculating the timing of astronomical events such as sunrise and sunset.
location( latitude = numeric(), longitude = numeric(), elevation = numeric(), zone = numeric() )location( latitude = numeric(), longitude = numeric(), elevation = numeric(), zone = numeric() )
latitude |
A numeric vector of latitudes |
longitude |
A numeric vector of longitudes |
elevation |
A numeric vector of elevations above sea level (in metres) |
zone |
A numeric vector of time zones (in hours, relative to UTC) |
A location vector object
melbourne <- location(-37.8136, 144.9631, 31, 10) sunrise("2025-01-01", melbourne)melbourne <- location(-37.8136, 144.9631, 31, 10) sunrise("2025-01-01", melbourne)
Lunar phase at date, as an angle in degrees. An angle of 0 means a new moon, 90 degrees means the first quarter, 180 means a full moon, and 270 degrees means the last quarter.
lunar_phase(date)lunar_phase(date)
date |
Date vector |
A numeric vector of angles in degrees representing the lunar phase at the given dates.
april2025 <- gregorian_date(2025, 4, 1:30) lunar_phase(april2025)april2025 <- gregorian_date(2025, 4, 1:30) lunar_phase(april2025)
There are three Mayan calendars: the famous "long count" calendar, the "Haab" calendar, and the "Tzolkin" calendar. Of these, only the long count calendar can be converted to and from other calendars, so it is the only one that has been implemented here.
mayan_date( baktun = integer(), katun = integer(), tun = integer(), uinal = integer(), kin = integer() ) as_mayan(date)mayan_date( baktun = integer(), katun = integer(), tun = integer(), uinal = integer(), kin = integer() ) as_mayan(date)
baktun |
Numeric vector |
katun |
Numeric vector |
tun |
Numeric vector |
uinal |
Numeric vector |
kin |
Numeric vector |
date |
Vector of dates on some calendar |
The Mayan long count calendar is a vigesimal (base-20) calendar with five components: kin (1 day), uinal (20 kin), tun (18 uinal), katun (20 tun), and baktun (20 katun). So the full cycle repeats every 20x18x20x20 = 144,000 days (approximately 394 years).
A mayan vector object
gregorian_date(2012, 12, 10:30) |> as_mayan()gregorian_date(2012, 12, 10:30) |> as_mayan()
Generate a calendar object of class "calendar". Examples of calendars
produced in this way include cal_chinese, cal_gregorian, cal_hebrew, cal_islamic,
and cal_iso.
new_calendar( name, short_name, granularities, validate_granularities, format, from_rd, to_rd ) cal_babylonian cal_bahai cal_balinese cal_chinese cal_japanese cal_korean cal_vietnamese cal_coptic cal_ethiopic cal_egyptian cal_armenian cal_french cal_afrench cal_gregorian cal_hebrew cal_icelandic cal_islamic cal_iso cal_julian cal_oislamic cal_saudi cal_ohebrew cal_samaritan cal_mayan cal_hindu_lunar cal_hindu_solar cal_old_hindu_solar cal_old_hindu_lunar cal_persian cal_apersian cal_roman cal_tibetannew_calendar( name, short_name, granularities, validate_granularities, format, from_rd, to_rd ) cal_babylonian cal_bahai cal_balinese cal_chinese cal_japanese cal_korean cal_vietnamese cal_coptic cal_ethiopic cal_egyptian cal_armenian cal_french cal_afrench cal_gregorian cal_hebrew cal_icelandic cal_islamic cal_iso cal_julian cal_oislamic cal_saudi cal_ohebrew cal_samaritan cal_mayan cal_hindu_lunar cal_hindu_solar cal_old_hindu_solar cal_old_hindu_lunar cal_persian cal_apersian cal_roman cal_tibetan
name |
Name of calendar |
short_name |
Short name of calendar |
granularities |
Character vector with names of granularities of calendar
(e.g., for the Gregorian calendar, the granularities are |
validate_granularities |
Function to check granularities are valid (e.g., Gregorian months should be between 1 and 12). |
format |
Function to specify date format as a character string. |
from_rd |
Function to convert from RD to calendar date. |
to_rd |
Function to convert from calendar date to RD. |
A calendar object of class "calendar"
cal_gregorian tibble::tibble( x = new_date(year = 2025, month = 5, day = 1:31, calendar = cal_gregorian), y = as_date(x, calendar = cal_islamic) )cal_gregorian tibble::tibble( x = new_date(year = 2025, month = 5, day = 1:31, calendar = cal_gregorian), y = as_date(x, calendar = cal_islamic) )
Calculate all the near-full or near-new moons in a vector of Gregorian years
new_moons(year) full_moons(year)new_moons(year) full_moons(year)
year |
A vector of Gregorian years |
A vector of Gregorian dates representing the full moons or new moons in the given years.
A vector of dates
full_moons(2025) new_moons(2025)full_moons(2025) new_moons(2025)
The modern Persian calendar was adopted in 1925 in Iran and in 1957 in Afghanistan. An alternative version
of the calendar, using only arithmetic (rather than astronomical) calculations is available as the apersian calendar.
persian_date(year = integer(), month = integer(), day = integer()) apersian_date(year = integer(), month = integer(), day = integer()) as_persian(date) as_apersian(date)persian_date(year = integer(), month = integer(), day = integer()) apersian_date(year = integer(), month = integer(), day = integer()) as_persian(date) as_apersian(date)
year |
Numeric vector of years |
month |
Numeric vector of months |
day |
Numeric vector of days |
date |
Vector of dates on some calendar |
A persian vector object
gregorian_date(2025, 5, 1:20) |> as_persian()gregorian_date(2025, 5, 1:20) |> as_persian()
The Roman calendar (as defined here) is the same as the Julian calendar but with different nomenclature. Rather than use a (year, month, day) triple for each date, it specifies dates using year, month, event, count.
roman_date( year = integer(), month = integer(), event = integer(), count = integer(), leap_day = logical() ) as_roman(date)roman_date( year = integer(), month = integer(), event = integer(), count = integer(), leap_day = logical() ) as_roman(date)
year |
A numeric vector of years |
month |
A numeric vector of months |
event |
A numeric vector of events: 1 = Kalends, 2 = Nones, 3 = Ides |
count |
A numeric vector of counts |
leap_day |
A logical vector indicating if day is a leap day |
date |
Vector of dates on some calendar |
A roman vector object
roman_date(66, 4, 1, 1, FALSE) new_date(year = 66, month = 4, event = 1, count = 1, leap_day = FALSE, calendar = cal_roman) as_roman("2016-01-01") tibble::tibble( x = seq(as.Date("2025-01-01"), as.Date("2025-12-31"), by = "day"), y = as_roman(x) )roman_date(66, 4, 1, 1, FALSE) new_date(year = 66, month = 4, event = 1, count = 1, leap_day = FALSE, calendar = cal_roman) as_roman("2016-01-01") tibble::tibble( x = seq(as.Date("2025-01-01"), as.Date("2025-12-31"), by = "day"), y = as_roman(x) )
Calculate the time of sunrise, sunset, moonrise and moonset at a specific location and date. The
time zone of the location is used as specified in the location object. No adjustments are made for
daylight saving.
sunrise(date, location) sunset(date, location) moonset(date, location) moonrise(date, location)sunrise(date, location) sunset(date, location) moonset(date, location) moonrise(date, location)
date |
Vector of dates on some calendar. |
location |
Vector of locations of class "location", usually the output from the |
Time of sunrise
melbourne <- location(-37.8136, 144.9631, 31, 10) sydney <- location(-33.8688, 151.2093, 3, 10) sunrise(gregorian_date(2025, 1, 1), c(melbourne, sydney)) sunset(gregorian_date(2025, 1, 1), c(melbourne, sydney)) moonrise(gregorian_date(2025, 1, 1), c(melbourne, sydney)) moonset(gregorian_date(2025, 1, 1), c(melbourne, sydney))melbourne <- location(-37.8136, 144.9631, 31, 10) sydney <- location(-33.8688, 151.2093, 3, 10) sunrise(gregorian_date(2025, 1, 1), c(melbourne, sydney)) sunset(gregorian_date(2025, 1, 1), c(melbourne, sydney)) moonrise(gregorian_date(2025, 1, 1), c(melbourne, sydney)) moonset(gregorian_date(2025, 1, 1), c(melbourne, sydney))
There are several Tibetan calendars. These functions implement the official Phuglugs version of the Kalachakra calendar, which is similar to the Hindu lunisolar calendars.
tibetan_date( year = integer(), month = integer(), leap_month = logical(), day = integer(), leap_day = logical() ) as_tibetan(date)tibetan_date( year = integer(), month = integer(), leap_month = logical(), day = integer(), leap_day = logical() ) as_tibetan(date)
year |
A numeric vector of years |
month |
A numeric vector of months |
leap_month |
A logical vector of leap months |
day |
A numeric vector of days |
leap_day |
A logical vector of leap days |
date |
A vector of dates on some calendar |
A tibetan_date object
gregorian_date(2025, 6, 1:10) |> as_tibetan()gregorian_date(2025, 6, 1:10) |> as_tibetan()
The Tibetan New Year occurs on the first day of the Tibetan calendar. These functions calculate the date given either a Gregorian year or a Tibetan year. Both return a Gregorian date.
tibetan_new_year(year) losar(t_year)tibetan_new_year(year) losar(t_year)
year |
A vector of Gregorian years |
t_year |
A vector of Tibetan years |
A vector of Gregorian dates corresponding to the Tibetan New Year
tibetan_new_year(2025:2028) losar(2152:2154)tibetan_new_year(2025:2028) losar(2152:2154)
Create a time object
time_of_day(hour = integer(), minute = integer(), second = numeric())time_of_day(hour = integer(), minute = integer(), second = numeric())
hour |
A numeric vector of hours |
minute |
A numeric vector of minutes |
second |
A numeric vector of seconds |
A time_of_day vector object, stored as a vctrs record containing hours, minutes and seconds.
Functions to return Gregorian dates for US holidays and other special days
us_memorial_day(year) us_independence_day(year) us_labor_day(year) us_election_day(year) us_daylight_saving_start(year) us_daylight_saving_end(year) unlucky_fridays(year)us_memorial_day(year) us_independence_day(year) us_labor_day(year) us_election_day(year) us_daylight_saving_start(year) us_daylight_saving_end(year) unlucky_fridays(year)
year |
Gregorian year |
A vector of Gregorian dates corresponding to the US holidays or special days.
us_memorial_day(2025) us_independence_day(2025) us_labor_day(2025) us_election_day(2025) us_daylight_saving_start(2025) us_daylight_saving_end(2025) unlucky_fridays(2025)us_memorial_day(2025) us_independence_day(2025) us_labor_day(2025) us_election_day(2025) us_daylight_saving_start(2025) us_daylight_saving_end(2025) unlucky_fridays(2025)
Functions to return Gregorian dates for various Jewish holidays
yom_kippur(year) passover(year) purim(year) ta_anit_esther(year) tishah_be_av(year) hanukkah(year) rosh_hashanah(year) sukkot(year) shavuot(year)yom_kippur(year) passover(year) purim(year) ta_anit_esther(year) tishah_be_av(year) hanukkah(year) rosh_hashanah(year) sukkot(year) shavuot(year)
year |
A numeric vector of Gregorian years |
A vector of dates on the Gregorian calendar
tibble::tibble( year = 2025:2030, ta_anit_esther = ta_anit_esther(year), purim = purim(year), passover = passover(year), shavuot = shavuot(year), tishah_be_av = tishah_be_av(year), rosh_hashanah = rosh_hashanah(year), yom_kippur = yom_kippur(year), sukkot = sukkot(year), hanukkah = hanukkah(year) )tibble::tibble( year = 2025:2030, ta_anit_esther = ta_anit_esther(year), purim = purim(year), passover = passover(year), shavuot = shavuot(year), tishah_be_av = tishah_be_av(year), rosh_hashanah = rosh_hashanah(year), yom_kippur = yom_kippur(year), sukkot = sukkot(year), hanukkah = hanukkah(year) )