Calendrical. Reform. Sweden
(Calendrical v1.1.0)
Copy Markdown
A composite calendar that tracks the historical calendar in use in Sweden.
Sweden's path from the Julian to the Gregorian calendar is the most unusual in
Europe, and makes a good demonstration of Calendrical.Composite: it splices
four calendars, drops a leap day, and includes the only known 30 February.
Transitions
(base) — the Julian calendar.
1700-03-01 — Sweden begins a gradual transition by omitting the leap day of 1700 (there is no 29 February 1700) and switches to the transitional
Calendrical.Reform.Sweden.Transitionalcalendar, which runs one day ahead of the Julian calendar.1712-03-01 — Sweden abandons the transition and reverts to the Julian calendar. To realign, an extra day — 30 February 1712 — is inserted at the end of the transitional period.
1753-03-01 — Sweden adopts the proleptic Gregorian calendar. The eleven days 18 February 1753 through 28 February 1753 are skipped.
Examples
# 30 February 1712 is a valid date in Sweden
iex> Calendrical.Reform.Sweden.valid_date?(1712, 2, 30)
true
# There is no 29 February 1700
iex> Calendrical.Reform.Sweden.valid_date?(1700, 2, 29)
false
# The eleven days lost to the 1753 Gregorian adoption
iex> Calendrical.Reform.Sweden.valid_date?(1753, 2, 20)
falseReference
For a source-referenced survey of how other territories moved to the
Gregorian calendar, see Calendrical.Reform and Giuseppe Giudice's
The adoption of the Gregorian calendar.
Summary
Functions
Identifies that the calendar is month based.
Identify the base calendar for a given date.
Identify the base calendar for a given iso_days.
Returns the calendar year as displayed on rendered calendars.
Defines the CLDR calendar type for this calendar.
Returns the cyclic year.
Returns {year, month, day} calculated from the number of
iso_days.
Returns the number of days since the calendar epoch for the
given year-month-day.
Calculates the day and era for the given date.
Calculates the day of the week for the given date.
Calculates the day of the year for the given date.
Returns the number of days in the given month.
Returns the number of days in the given year/month.
Returns the number of days in a week.
Returns the number of days in the given year.
Returns the extended year.
Calculates the ISO week of the year for the given date.
Returns whether the given year is a leap year, in the context of the calendar in effect on the first day of that year.
Returns a Date.Range representing a given month of a year.
Calculates the month of the year for the given date.
Converts a Calendar.iso_days/0 to the datetime form for
this calendar.
Returns the Calendar.iso_days/0 form of the specified
datetime.
Returns the number of periods in the given year.
Adds an increment number of :months or :quarters to the
given year-month-day. Delegates to whichever base calendar is
in effect on the input date.
Returns a Date.Range representing a given quarter of a year.
Calculates the quarter of the year (1..4) for the given date.
Returns the related Gregorian year.
Shifts a date by the given duration.
Determines if the date given is valid according to this calendar.
Returns a Date.Range representing a given week of a year.
Composite calendars do not define week-of-month.
Calculates the week of the year for the given date.
Returns the number of weeks in the given year (in the context of the calendar that starts the year).
Returns a Date.Range representing a given year.
Calculates the year and era from the given year, month,
and day. The result is in the context of the calendar in
effect on that date.
Types
Functions
Identifies that the calendar is month based.
This may not always be true for all dates in a composite calendar but only a single value per calendar is supported.
Identify the base calendar for a given date.
This function derives the calendar we delegate to for a given date based upon the configuration.
Identify the base calendar for a given iso_days.
@spec calendar_year(Calendar.year(), Calendar.month(), Calendar.day()) :: Calendar.year()
Returns the calendar year as displayed on rendered calendars.
Defines the CLDR calendar type for this calendar.
This type is used in support of Calendrical.localize/3.
@spec cyclic_year(Calendar.year(), Calendar.month(), Calendar.day()) :: Calendar.year()
Returns the cyclic year.
Returns {year, month, day} calculated from the number of
iso_days.
Returns the number of days since the calendar epoch for the
given year-month-day.
Calculates the day and era for the given date.
Calculates the day of the week for the given date.
Calculates the day of the year for the given date.
Returns the number of days in the given month.
Composite calendars cannot answer this without a year so the
default implementation returns {:error, :undefined}.
Returns the number of days in the given year/month.
Returns the number of days in a week.
Returns the number of days in the given year.
@spec extended_year(Calendar.year(), Calendar.month(), Calendar.day()) :: Calendar.year()
Returns the extended year.
Calculates the ISO week of the year for the given date.
Returns whether the given year is a leap year, in the context of the calendar in effect on the first day of that year.
Returns a Date.Range representing a given month of a year.
Calculates the month of the year for the given date.
Converts a Calendar.iso_days/0 to the datetime form for
this calendar.
@spec naive_datetime_to_iso_days( Calendar.year(), Calendar.month(), Calendar.day(), Calendar.hour(), Calendar.minute(), Calendar.second(), Calendar.microsecond() ) :: Calendar.iso_days()
Returns the Calendar.iso_days/0 form of the specified
datetime.
Returns the number of periods in the given year.
Adds an increment number of :months or :quarters to the
given year-month-day. Delegates to whichever base calendar is
in effect on the input date.
Returns a Date.Range representing a given quarter of a year.
Calculates the quarter of the year (1..4) for the given date.
Shifts a date by the given duration.
Determines if the date given is valid according to this calendar.
Returns a Date.Range representing a given week of a year.
Not all base calendars define weeks; the result depends on the calendar in effect on 1 January of the given year.
Composite calendars do not define week-of-month.
Calculates the week of the year for the given date.
Returns the number of weeks in the given year (in the context of the calendar that starts the year).
Returns a Date.Range representing a given year.
@spec year_of_era(year(), month(), day()) :: {year(), era :: non_neg_integer()}
Calculates the year and era from the given year, month,
and day. The result is in the context of the calendar in
effect on that date.