Calendrical. Calendar. Shifted
(Calendrical v2.2.0)
Copy Markdown
Makes a calendar whose year begins elsewhere in a base calendar's year: a fiscal year beginning in July, a year counted from Lady Day as the Old Style did, or any year begun on a day of a calendar of months.
A date of the calendar is a counted month and a day of it, so dates order by time. A year that begins on the first day of a base month has the base's months counted from that month; a year that begins within a base month has a short month 1, from the day it begins on to the end of that base month, and a short last month, the days of that base month before it, so a year begun on 25 March has thirteen months, of which month 1 is 25 to 31 March and month 13 is 1 to 24 March.
The kernel falls out of the base: a date is the base's date relabelled,
a month's length is the base month's, and shift/6 is the base's
arithmetic on the base date, relabelled.
Options
:baseis the calendar of months the year is cut from, a calendar with as many months in every year. The default isCalendrical.Gregorian.:year_beginsis{month, day}of the base calendar the year begins on. The default is{1, 1}.:year_numberis the base year the year takes its number from::beginning, the one it begins in,:ending, the one it ends in, or:majority, the one most of it falls in, which is the default.:written_yearis the year a date is written with::base, the base calendar's year the day falls in, as a fiscal date is written with the Gregorian year, which is the default, or:label, the calendar's own year, as the Old Style wrote its dates.:weeksis the rule the calendar's own weeks follow: a keyword list with:first_day, 1 for Monday to 7 for Sunday, and:min_days_in_first_week, or:from_first_dayfor weeks counted from the first day of the year. The default is Monday and 1.:cldr_calendar_type,:era_calendar_typeand:years_in_cycleare facts forCalendrical.info/0, each defaulting to the base calendar's, and:parsing_calendarnames the calendar a written date is parsed in, the calendar itself by default.
Examples
defmodule FiscalFromJuly do
use Calendrical.Calendar.Shifted, year_begins: {7, 1}, year_number: :ending
end
defmodule LadyDay do
use Calendrical.Calendar.Shifted,
base: Calendrical.Julian,
year_begins: {3, 25},
year_number: :beginning,
written_year: :label
end