Index

Functions

Calendars.CDateType

A CDate (short for Calender Date) is defined as

CDate = Tuple{DPart, DPart, DPart, DPart}
A tuple `date` of type `CDate` is unpacked by convention as
(calendar, year, month, day), where `calendar` is one of
"European" 
"Common" 
"Julian" 
"Hebrew" 
"Islamic" 
"IsoDate"
Alternatively the acronyms
EC, CE, JD, AM, AH, and ID 
can be used. "Common" or CE denotes the proleptic Gregorian calendar
and `DPart` (date part) is a typename for Int64.
CDateStr(cd::CDate) 

The function CDateStr converts a date of type CDate to a string representation, where the numeric part follows the recommendation of ISO 8601 and is prefixed by one of the acronyms for the calendar names indicated above.

Examples for CDates and their string representation given by CDateStr:

("European", 2022,  1,  6)  -> "EC-2022-01-06"
("Common",   2022,  1, 19)  -> "CE-2022-01-19"
("Julian",   2022,  1,  6)  -> "JD-2022-01-06"
("Hebrew",   5782, 11, 17)  -> "AM-5782-11-17"
("Islamic",  1443,  6, 15)  -> "AH-1443-06-15"
("IsoDate",  2022,  3,  3)  -> "ID-2022-03-03"

The components of a CDate can be accessed by applying the functions

Calendar, Year, Month, Day and Date 

to a calendar date.

The function CalendarName(CC) returns the calendar name from a calendar specifier CC. For example both CalendarName(ID) and CalendarName(6) return the string "IsoDate".

Calendars.DayNumberFromDateFunction
DayNumberFromDate(date::Cdate, string::Bool, show::Bool)

Return the day number correspondig to the calendar date. The parts of the date can also be given separately.

If the optional parameter string is true the function returns the day number in string format, otherwise as an integer. string is 'false' by default.

If the optional parameter show is 'true', date and number are printed. show is 'false' by default.

For example:

julia> DayNumberFromDate("Gregorian", 1756, 1, 27) 

Using the acronym CE for 'Common Epoch' which is synonymous with 'Gregorian', this can also be written as

julia> DayNumberFromDate(CE, 1756, 1, 27) 

This returns the European day number 641027 as an integer by default. If string is true the string "EN#641029" is returned. If show is true the line "CE-1756-01-27 -> EN#641029" is printed.

If an error occurs 0 (representing the invalid day number) is returned.

Calendars.DateFromDayNumberFunction
DateFromDayNumber(calendar::DPart, enum::DPart, string::Bool, show::Bool)

Return the date from a European day number expressed in the calendar.

The day number enum must be an integer >= 1.

If the optional parameter string is true the function returns the date as a string, otherwise as an integer tuple. string is false by default.

If the optional parameter show is set to true, date and number are printed. show is false by default.

For example:

julia> DateFromDayNumber("Gregorian", 641029) 

Alternatively you can also write

julia> DateFromDayNumber(CE, 641029) 

By default this returns the calendar representation (2, 1756, 1, 27). If string is true the string "CE-1756-01-27" is returned. If show is 'true' the line "EN#0641029 -> CE-1756-01-27" is printed.

If an error occurs (0, 0, 0, 0) (representing the invalid date) is returned.

Calendars.ConvertDateFunction
ConvertDate(date::CDate, calendar::DPart, string::Bool, show::Bool)

Convert the given date to a date in the calendar calendar. Admissible names for the calendar are listed in the CDate docstring.

If the optional parameter string is true the function returns the date as a string, otherwise as an integer tuple. string is false by default.

If the optional parameter show is set to 'true', both dates are printed. show is 'false' by default.

For example:

julia> ConvertDate(CE, 1756, 1, 27, AM) 

Alternatively this can also be written as

julia> ConvertDate("Gregorian", 1756, 1, 27, "Hebrew") 

This converts the Gregorian date (1756, 1, 27) to the Hebrew date (5516, 11, 25). By default the calendar representation (4, 5516, 11, 25) is returned.

If string is true the string "AM-5516-11-25" is returned. If show is 'true' the following line is printed:

    "CE-1756-01-27 -> AM-5516-11-25"

If an error occurs (0, 0, 0, 0) (representing the invalid date) is returned.

Calendars.ConvertOrdinalDateFunction
ConvertOrdinalDate(num::DPart, from::String, to::String)

num is an ordinal date, i.e. an integer counting the ellapsed days since the beginning of a calendrial epoch.

from and to are ordinal date names. Currently only the ordinal date names "EuroNum" and "JulianNum", respectively their acronyms EN, JN, are admissible.

Examples: Convert a Julian day number to an European day number.

julia> ConvertOrdinalDate(2440422, JN, EN) 

The European day number of the first crewed moon landing is 719000.

Convert an European day number to an Julian day number.

julia> ConvertOrdinalDate(719000, EN, JN) 

The Julian day number of the first crewed moon landing is 2440422.

Calendars.CalendarDatesFunction
CalendarDates(date::CDate, show::Bool)

Return a table of the dates of all supported calendars corresponding to date. If the optional parameter show is set to 'true', the date table is printed. show is 'false' by default.

julia> CalendarDates("Gregorian", 1756, 1, 27, true) 

Alternatively you can also write

julia> CalendarDates(CE, 1756, 1, 27, true) 

This computes a DateTable, which is a tuple of six calendar dates plus the Euro day number and the Julian day number. If show is 'true' the table below will be printed.

    European  EC-1756-01-27
    Common    CE-1756-01-27
    Julian    JD-1756-01-16
    Hebrew    AM-5516-11-25
    Islamic   AH-1169-04-24
    IsoDate   ID-1756-05-02
    EuroNum   EN#0641029
    JulianNum JN#2362452
Calendars.isValidDateFunction
isValidDate(date::CDate, warn=true)::Bool

Query if the given date` is a valid calendar date.

For example:

julia> isValidDate("Gregorian", 1756, 1, 27) 

Alternatively you can also write

julia> isValidDate(CE, 1756, 1, 27) 

This query affirms that 1756-01-27 is a valid Gregorian date. But the next two queries return 'false' and 'true', respectively.

julia> isValidDate(CE, 1900, 2, 29)

julia> isValidDate(JD, 1900, 2, 29)
Calendars.DayOfYearFunction
DayOfYear(date::CDate)

Return the ordinal of the day in the given calendar. Also known as the 'ordinal date' relative to the epoch of the calendar.

julia> DayOfYear(EC, 1756, 1, 27) 

Alternatively you can write

julia> DayOfYear("European", 1756,  1, 27) 

From the output we see that EC-1756-01-27 is the 27-th day of the year 1756 in the European calendar. The same day is in the Hebrew calendar the 144-th day of the year:

julia julia> DayOfYear(ConvertDate(EC, 1756, 1, 27, AM))

If an error occurs 0 (representing the invalid day of the year) is returned.

Calendars.DurationFunction
Duration(a::CDate, b::CDate, show=false)

The duration gives the number of days between the two dates a and b, counting the first date but not the second. So it describes a right half-open time interval. The start and end dates can be given in different calendars.

If the optional parameter show is set to 'true', both dates are printed. show is 'false' by default.

julia> Duration((CE, 2022, 1, 1), (ID, 2022, 1, 1), true)

Perhaps to the surprise of some, these dates are two days apart.

    CE-2022-01-01 <-> ID-2022-01-01 -> Duration 2
Calendars.PrintDateLineFunction
PrintDateLine(date::CDate, io=stdout)

Given a date print a line with all representations of this date to io. The parts of the date can also be given separately. For example:

julia> PrintDateLine(EC, 2022, 2, 2)

| CE-2022-02-02 | EC-2022-02-02 | JD-2022-01-20 | AM-5782-12-01 | AH-1443-06-29 | ID-2022-05-03 | EN#0738190 | JN#2459612 |

Calendars.PrintEuropeanMonthFunction
PrintEuropeanMonth(year::DPart, month::DPart, io=stdout)

Print a calendar for the given European month as a markdown table to io.

For example:

julia> PrintEuropeanMonth(2022, 2)
Calendars.SaveEuropeanMonthFunction
SaveEuropeanMonth(year::DPart, month::DPart, dirname:String)

Save the calendar of the given European month as a markdown table to a file in the directory dirname. If no directory is given the file is written to the execution directory.

For example:

julia> SaveEuropeanMonth(2022, 2)
Calendars.PrintIsoWeekFunction
PrintIsoWeek(year::DPart, week::DPart, io=stdout)

Print a calendar for the given Iso week as a markdown table to io.

For example:

julia> PrintIsoWeek(2022, 2)
Calendars.ProfileYearAsEuropeanFunction
ProfileYearAsEuropean(calendar::DPart, year::DPart, show=false)

Return a 4-tuple (YearStart, YearEnd, MonthsInYear, DaysInYear) as represented in the European calendar.

Jewish New Year (Rosh HaShanah) begins the evening before the date returned. For the ISO-calendar read 'WeeksInYear' instead of 'MonthsInYear'.

Examples:

julia> ProfileYearAsEuropean(EC, 2022, true) 
julia> ProfileYearAsEuropean(CE, 2022, true) 
julia> ProfileYearAsEuropean(JD, 2022, true) 
julia> ProfileYearAsEuropean(AM, 5783, true) 
julia> ProfileYearAsEuropean(AH, 1444, true) 
julia> ProfileYearAsEuropean(ID, 2022, true) 

These commands return:

EC-2022 -> [EC-2022-01-01, EC-2022-12-31], 12, 365
CE-2022 -> [EC-2022-01-01, EC-2022-12-31], 12, 365
JD-2022 -> [EC-2022-01-14, EC-2023-01-13], 12, 365
AM-5783 -> [EC-2022-09-26, EC-2023-09-15], 12, 355
AH-1444 -> [EC-2022-07-30, EC-2023-07-18], 12, 354
ID-2022 -> [EC-2022-01-03, EC-2023-01-01], 52, 364
Calendars.IDateFunction

Interactively query the dates for all calendars in the REPL.

julia> IDate()