Calendrical. Reform. Sweden. Transitional
(Calendrical v1.1.0)
Copy Markdown
The transitional "Swedish calendar" in use between 1700 and 1712.
In 1700 Sweden began a gradual transition to the Gregorian calendar by omitting the leap day that year (there was no 29 February 1700). The plan was to drop every leap day from 1700 to 1740, at which point Sweden would have aligned with the Gregorian calendar. The plan was abandoned after 1700, so for the years 1700 to 1712 Sweden ran a unique calendar that was one day ahead of the Julian calendar and ten days behind the Gregorian calendar.
In 1712 Sweden reverted to the Julian calendar by inserting a second leap day that year — the only known instance of a 30 February. From 1 March 1712 the calendar realigned with the Julian calendar.
This module models that transitional calendar. It is not intended for direct
use; it exists as the 1700–1712 segment of the Calendrical.Reform.Sweden composite
calendar. Within that window each date maps to the same physical day as the
Julian date bearing the same numbers, shifted back by one day, and the date
30 February 1712 is valid.
Summary
Functions
Identifies whether this calendar is month or week based.
Returns the calendar year as displayed on rendered calendars.
Defines the CLDR calendar type for this calendar.
Returns the cyclic year as displayed on rendered calendars.
Converts an ISO day number to a {year, month, day} in the transitional
Swedish calendar.
Converts a year, month and day in the transitional Swedish calendar to
an ISO day number.
Calculates the day and era from the given
year, month, and day.
Calculates the day of the year from the given
year, month, and day.
Returns how many days there are in the given month.
Returns how many days there are in the given year and month.
Returns the number days in a a week.
Returns the number days in a given year.
Returns the extended year as displayed on rendered calendars.
Calculates the ISO week of the year from the
given year, month, and day.
Returns whether year is a leap year in the transitional Swedish calendar.
Returns a Date.Range.t/0 representing
a given month of a year.
Returns the month of the year from the given
year, month, and day.
Returns the number of months in a leap year.
Returns the number of months in a normal year.
Returns the number of months in a year, without a year.
Returns the number of months in a
given year.
Converts the t:Calendar.iso_days format to the
datetime format specified by this calendar.
Returns the t:Calendar.iso_days format of
the specified date.
Returns the number of periods in a given
year. A period corresponds to a month
in month-based calendars and a week in
week-based calendars.
Adds an increment number of date_parts
to a year-month-day.
Returns a Date.Range.t/0 representing
a given quarter of a year.
Returns the quarter of the year from the given
year, month, and day.
Returns the related Gregorian year as displayed on rendered calendars.
Determines if the date given is valid according to
this calendar.
Returns a Date.Range.t/0 representing
a given week of a year.
Calculates the week of the year from the given
year, month, and day.
Calculates the week of the year from the given
year, month, and day.
Returns the number of weeks in a
given year.
Returns a Date.Range.t/0 representing
a given year.
Calculates the year and era from the given year.
Calculates the year and era from the given date.
Functions
Identifies whether this calendar is month or week based.
@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 as displayed on rendered calendars.
@spec date_from_iso_days(Calendrical.iso_day_number()) :: {Calendar.year(), Calendar.month(), Calendar.day()}
Converts an ISO day number to a {year, month, day} in the transitional
Swedish calendar.
Arguments
iso_daysis an integer ISO day number within the 1700–1712 window.
Returns
- A
{year, month, day}tuple.
Examples
iex> Calendrical.Reform.Sweden.Transitional.date_from_iso_days(
...> Calendrical.Julian.date_to_iso_days(1712, 2, 29))
{1712, 2, 30}
@spec date_to_iso_days(Calendar.year(), Calendar.month(), Calendar.day()) :: Calendrical.iso_day_number()
Converts a year, month and day in the transitional Swedish calendar to
an ISO day number.
Arguments
year,monthanddayare the parts of a Swedish calendar date in the 1700–1712 window (30 February 1712 is accepted).
Returns
- The integer ISO day number of the given date.
Examples
iex> Calendrical.Reform.Sweden.Transitional.date_to_iso_days(1712, 2, 30) ==
...> Calendrical.Julian.date_to_iso_days(1712, 2, 29)
true
@spec day_of_era(Calendar.year(), Calendar.month(), Calendar.day()) :: {day :: Calendar.day(), era :: Calendar.era()}
Calculates the day and era from the given
year, month, and day.
By default we consider on two eras: before the epoch and on-or-after the epoch.
@spec day_of_year(Calendar.year(), Calendar.month(), Calendar.day()) :: Calendar.day()
Calculates the day of the year from the given
year, month, and day.
@spec days_in_month(Calendar.month()) :: Calendar.month() | {:ambiguous, Range.t() | [pos_integer()]} | {:error, :undefined}
Returns how many days there are in the given month.
Must be implemented in derived calendars because we cannot know what the calendar format is.
@spec days_in_month(Calendar.year(), Calendar.month()) :: Calendar.month()
Returns how many days there are in the given year and month.
Returns the number days in a a week.
Returns the number days in a given year.
The year is the number of years since the epoch.
@spec extended_year(Calendar.year(), Calendar.month(), Calendar.day()) :: Calendar.year()
Returns the extended year as displayed on rendered calendars.
@spec iso_week_of_year(Calendar.year(), Calendar.month(), Calendar.day()) :: {:error, :not_defined}
Calculates the ISO week of the year from the
given year, month, and day.
By default this function always returns
{:error, :not_defined}.
@spec leap_year?(Calendar.year()) :: boolean()
Returns whether year is a leap year in the transitional Swedish calendar.
Leap years follow the Julian rule; 1712 additionally carried the extra 30 February day.
Arguments
yearis the year to test.
Returns
- A boolean.
Examples
iex> Calendrical.Reform.Sweden.Transitional.leap_year?(1704)
true
Returns a Date.Range.t/0 representing
a given month of a year.
@spec month_of_year(Calendar.year(), Calendar.month(), Calendar.day()) :: Calendar.month() | {Calendar.month(), Calendrical.leap_month?()}
Returns the month of the year from the given
year, month, and day.
Returns the number of months in a leap year.
Returns the number of months in a normal year.
Returns the number of months in a year, without a year.
Returns an integer when every year has the same number of
months, or {:ambiguous, first..last} for lunisolar calendars
whose year length varies (e.g. the Hebrew calendar's 12 or 13
months).
Returns the number of months in a
given year.
@spec naive_datetime_from_iso_days(Calendar.iso_days()) :: {Calendar.year(), Calendar.month(), Calendar.day(), Calendar.hour(), Calendar.minute(), Calendar.second(), Calendar.microsecond()}
Converts the t:Calendar.iso_days format to the
datetime format specified by 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 t:Calendar.iso_days format of
the specified date.
Returns the number of periods in a given
year. A period corresponds to a month
in month-based calendars and a week in
week-based calendars.
Adds an increment number of date_parts
to a year-month-day.
date_part can be :years, :months, :weeks or :days.
Returns a Date.Range.t/0 representing
a given quarter of a year.
@spec quarter_of_year(Calendar.year(), Calendar.month(), Calendar.day()) :: Calendrical.quarter()
Returns the quarter of the year from the given
year, month, and day.
Determines if the date given is valid according to
this calendar.
Returns a Date.Range.t/0 representing
a given week of a year.
@spec week_of_month(Calendar.year(), Calendar.month(), Calendar.day()) :: {pos_integer(), pos_integer()} | {:error, :not_defined}
Calculates the week of the year from the given
year, month, and day.
By default this function always returns
{:error, :not_defined}.
@spec week_of_year(Calendar.year(), Calendar.month(), Calendar.day()) :: {:error, :not_defined}
Calculates the week of the year from the given
year, month, and day.
By default this function always returns
{:error, :not_defined}.
Returns the number of weeks in a
given year.
Returns a Date.Range.t/0 representing
a given year.
@spec year_of_era(Calendar.year()) :: {year :: Calendar.year(), era :: Calendar.era()}
Calculates the year and era from the given year.
@spec year_of_era(Calendar.year(), Calendar.month(), Calendar.day()) :: {year :: Calendar.year(), era :: Calendar.era()}
Calculates the year and era from the given date.