Calendrical. Ethiopic. AmeteAlem
(Calendrical v2.2.0)
Copy Markdown
Implementation of the Ethiopic calendar with the Amete Alem (Era of the World, Anno Mundi) year numbering.
This calendar is structurally identical to Calendrical.Ethiopic โ
same 13-month layout, same leap-year rule, same days-in-month โ but
the year is counted from the traditional Ethiopian Christian date
of the creation of the world rather than from the Era of Mercy:
amete_alem_year = amete_mihret_year + 5500So 1 Amete Alem = -5499 Julian = -5492-07-17 proleptic Gregorian (per CLDR era data) and modern Ethiopic year 2017 (Amete Mihret) = 7517 Amete Alem.
Days are assumed to begin at midnight rather than at sunset.
Reference
Dershowitz & Reingold, Calendrical Calculations (4th ed.), ยง4.2 ("Ethiopic and Coptic Calendars").
CLDR
:ethiopic_amete_alemcalendar type. The CLDR era data places the aa era at proleptic Gregorian-5492-07-17.
See Calendrical.Ethiopic for the month structure and the
mod(year, 4) == 3 leap-year rule.
Summary
Functions
Adds whole years, quarters or months to the fields of a naive
datetime, keeping its time of day: the add/9 callback
CalendarInterval steps an
interval of a year or a month with. The date moves as shift/6
moves it, clamping the day into a shorter month.
Returns the Amete Alem year for the given Amete Mihret
(Calendrical.Ethiopic) year.
Returns the corresponding Calendrical.Ethiopic (Amete Mihret)
year for the given Amete Alem year.
Returns what this calendar's year is built of, :month or :week,
as its info/0 states.
Returns the calendar module whose CLDR calendar type is the one
given, whichever calendar is asked
(Calendrical.calendar_from_cldr_calendar_type/1).
Returns the day a date is written with: the day of its
written_date/3.
Returns the CLDR month a month of the year names without a year
(Calendrical.Month.cldr_month/2).
Returns the year a date is written with: the year of its
written_date/3.
Returns the CLDR calendar type whose data names this calendar's
months, days and quarters, as its info/0 states.
Returns the CLDR calendar type whose data names a date's months and
days: the member in effect on the date in a composite calendar, and
this calendar's own otherwise (Calendrical.Info.cldr_calendar_type/4).
Returns the CLDR month of a month of a year
(Calendrical.Month.cldr_month/3).
Returns the cyclic year of a date (Calendrical.Era.cyclic_year/4).
Returns the date of this calendar that written figures name
(date_from_written_date/3), as fields.
Returns the date of a day of a year, counted from the year's first day.
Returns an Amete Alem {year, month, day} tuple for the given
ISO day number.
Returns the date of a day of a week of a week-year
(Calendrical.Week.date_from_week_date/4).
Returns the date of this calendar that written figures name: the
inverse of written_date/3, the fields themselves where they are a
date.
Returns the number of ISO days for the given Amete Alem year,
month, and day.
Returns the dates of this calendar, earliest first, whose month and day are those given and that fall in a Gregorian year.
Returns the days a month of a year has, as runs of their numbers
(Calendrical.Month.day_numbers/3).
Returns the day of era and era of a date (Calendrical.Era.day_of_era/4).
Returns the day of the week of a date (Calendrical.Week.day_of_week/5).
Returns the day of the year of a date (Calendrical.Period.day_of_year/4).
Returns the number of days in a month without a year
(Calendrical.Month.days_in_month/2).
Returns the number of days in the given Amete Alem year and
month.
Returns the fewest and the most days a month has in any year
(Calendrical.Month.days_in_month_bounds/2).
Returns the number of days in a week.
Returns the number of days in a year (Calendrical.Period.days_in_year/2).
Returns the number of whole units between two dates, counted positionally.
Returns the epoch of this calendar: the ISO day number of its first day.
Returns the CLDR calendar type that names this calendar's eras, as
its info/0 states.
Returns the offset (in years) between the Amete Alem (Era of the
World) and the Amete Mihret (Era of Mercy) used by
Calendrical.Ethiopic.
Returns the extended year of a date (Calendrical.Era.extended_year/4).
Returns the static facts about this calendar, as
Calendrical.Info.t/0.
Returns the ISO 8601 week-year and week of the day a date names
(Calendrical.Week.iso_week_of_year/4).
Returns the position of a year's leap month, or nil where the
year has none.
Returns whether the given Amete Alem year is a leap year.
Returns the traditional month at a position in a year
(Calendrical.Month.traditional_month/3), or an error for a place
the year does not have.
Returns the days of a month of a year (Calendrical.Period.month/3).
Returns the position of a traditional month in a year
(Calendrical.Month.month_from_traditional/3).
Returns the months a year has, as runs of their numbers
(Calendrical.Month.month_numbers/2).
Returns the CLDR month of a month of a year: the index of its name
in this calendar's CLDR data, with {month, :leap} where the name
has a leap form (Calendrical.Month.cldr_month/3).
Returns the number of months in a leap year: the most months a year of this calendar has.
Returns the number of months in an ordinary year: the fewest months a year of this calendar has.
Returns the number of months in a year without a year: the count
where every year has as many, {:ambiguous, range} where a leap
year has more, and {:error, %Calendrical.NotDefinedError{}} for a composite calendar
(Calendrical.Info.months_in_year/1).
Returns the number of months in a
given year.
Returns the fewest and the most months a year has
(Calendrical.Month.months_in_year_bounds/1).
Converts ISO days and a day fraction to a naive datetime of this
calendar, as Calendar.naive_datetime_from_iso_days/1 asks.
Converts a naive datetime of this calendar to ISO days and a day
fraction, as Calendar.naive_datetime_to_iso_days/7 asks.
Returns the days of a named month in a year
(Calendrical.Month.named_month/3).
Returns the number a date's month is written with in figures: the
month of its written_date/3.
Returns the position in a year of a traditional month
(Calendrical.Month.month_from_traditional/3), as {:ok, month}.
Parses a date written in this calendar's own notation.
Parses a naive datetime written in this calendar's own notation.
Parses a UTC datetime written in this calendar's own notation.
Returns the calendar a date written for this calendar is parsed in,
as its info/0 states.
Returns the calendars a date written for this calendar may be
written in: the members of a composite calendar, and this calendar
alone otherwise (Calendrical.Info.parsing_calendars/1).
Returns the number of periods in a year: its months.
Returns the days of a quadrimester of a year
(Calendrical.Period.quadrimester/3).
Returns the days of a quarter of a year (Calendrical.Period.quarter/3).
Returns the quarter of the year a date falls in
(Calendrical.Period.quarter_of_year/4).
Returns the related Gregorian year of a date
(Calendrical.Era.related_gregorian_year/4).
Returns the days of a semester of a year (Calendrical.Period.semester/3).
Returns the date a number of years, quarters, months, weeks or days
on from a date of this calendar, by position, with the traditional
month kept across years and a day the resulting month lacks clamped
to its last day unless clamp: false (Calendrical.Shift.shift/7).
Shifts a date by a duration: its years and months together, as
shift/6 adds months, and then its weeks and days.
Shifts a naive datetime by a duration: its date as shift_date/4
shifts it, and its time as Calendar.ISO does.
Shifts a time by a duration, as Calendar.ISO does.
Returns the day of a solar term of a Gregorian year, reckoned at the
place this calendar's info/0 names, or at the Chinese calendar's
meridian, the traditional reference, where it names none.
Returns the traditional number of the month a year's leap month
follows, or nil (Calendrical.Month.traditional_leap_month/2).
Returns a month of a year as this calendar names it
(Calendrical.Month.traditional_month/3).
Returns a year's months in order, named traditionally
(Calendrical.Month.traditional_months/2).
Returns whether the given year, month, and day form a valid
Amete Alem date.
Returns the seven days of a week of a year (Calendrical.Week.week/3).
Returns the week-year, the week and the day of the week of a date
(Calendrical.Week.week_date_from_date/4).
Returns the month and the week of the month a date is in
(Calendrical.Week.week_of_month/4).
Returns the week-year and the week of the year a date is in
(Calendrical.Week.week_of_year/4).
Returns the number of weeks in a week-year
(Calendrical.Week.weeks_in_week_year/2).
Returns the number of weeks in a year (Calendrical.Week.weeks_in_year/2).
Returns the weeks of a month of a year in order
(Calendrical.Week.weeks_of_month/3).
Returns the figures a date is written with: its own fields, in a calendar whose dates are written as its own.
Returns the month a CLDR month is written with in a year
(Calendrical.Month.written_month_from_cldr_month/3).
Returns the days of a year (Calendrical.Period.year/2).
Returns the year of era and era of a year (Calendrical.Era.year_of_era/2).
Returns the year of era and era of a date (Calendrical.Era.year_of_era/4).
Returns the number of years after which this calendar's years
repeat, as its info/0 states, or {:error, %Calendrical.NotDefinedError{}}.
Types
Functions
Adds whole years, quarters or months to the fields of a naive
datetime, keeping its time of day: the add/9 callback
CalendarInterval steps an
interval of a year or a month with. The date moves as shift/6
moves it, clamping the day into a shorter month.
Arguments
year,monthanddayare the date's fields in this calendar.hour,minute,secondandmicrosecondare the time of day, returned unchanged.precisionis:year,:quarteror:month.stepis the number of years, quarters or months to add, which may be negative.
Returns
{year, month, day, hour, minute, second, microsecond}.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {year, month, day, 12, 30, 0, {0, 0}} =
...> Calendrical.Ethiopic.AmeteAlem.add(date.year, date.month, date.day, 12, 30, 0, {0, 0}, :month, 1)
iex> {year, month, day} == Calendrical.Ethiopic.AmeteAlem.shift(date.year, date.month, date.day, :months, 1, [])
true
Returns the Amete Alem year for the given Amete Mihret
(Calendrical.Ethiopic) year.
Arguments
amete_mihret_yearis any Amete Mihret (Ethiopic) year as an integer.
Returns
- An integer Amete Alem year (5500 more than the input).
Examples
iex> Calendrical.Ethiopic.AmeteAlem.amete_alem_year(2018)
7518
Returns the corresponding Calendrical.Ethiopic (Amete Mihret)
year for the given Amete Alem year.
Arguments
amete_alem_yearis any Amete Alem year as an integer.
Returns
- An integer Amete Mihret year (5500 less than the input).
Examples
iex> Calendrical.Ethiopic.AmeteAlem.amete_mihret_year(7518)
2018
Returns what this calendar's year is built of, :month or :week,
as its info/0 states.
Returns
:weekfor a calendar whose year is built of weeks.:monthotherwise.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.calendar_base() in [:month, :week]
true
Returns the calendar module whose CLDR calendar type is the one
given, whichever calendar is asked
(Calendrical.calendar_from_cldr_calendar_type/1).
Arguments
calendar_typeis a CLDR calendar type as an atom or a string.
Returns
{:ok, calendar_module}, or{:error, exception}for a calendar type no calendar module has.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.calendar_from_cldr_calendar_type(:gregorian)
{:ok, Calendrical.Gregorian}
iex> {:error, %Localize.UnknownCalendarError{}} =
...> Calendrical.Ethiopic.AmeteAlem.calendar_from_cldr_calendar_type(:not_a_calendar)
Returns the day a date is written with: the day of its
written_date/3.
Arguments
year,monthanddayare a date of this calendar.
Returns
The day of the date's
written_date/3, or{:error, %Calendrical.InvalidDateError{}}for a date the calendar does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {_year, _month, written_day} = Calendrical.Ethiopic.AmeteAlem.written_date(date.year, date.month, date.day)
iex> Calendrical.Ethiopic.AmeteAlem.cardinal_day(date.year, date.month, date.day) == written_day
true
Returns the CLDR month a month of the year names without a year
(Calendrical.Month.cldr_month/2).
Arguments
monthis a month of this calendar.
Returns
- The CLDR month the month is named in the year that holds 1 January 2000, the month itself in the Hebrew calendar, whose names depend on the year, and the month itself where the reference year has no such month.
Examples
iex> {:ok, date} = Date.convert(~D[2000-01-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.cardinal_month(1) == Calendrical.Ethiopic.AmeteAlem.cldr_month(date.year, 1)
true
Returns the year a date is written with: the year of its
written_date/3.
Arguments
year,monthanddayare a date of this calendar.
Returns
The year of the date's
written_date/3, or{:error, %Calendrical.InvalidDateError{}}for a date the calendar does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {written_year, _month, _day} = Calendrical.Ethiopic.AmeteAlem.written_date(date.year, date.month, date.day)
iex> Calendrical.Ethiopic.AmeteAlem.cardinal_year(date.year, date.month, date.day) == written_year
true
Returns the CLDR calendar type whose data names this calendar's
months, days and quarters, as its info/0 states.
Returns
- A CLDR calendar type such as
:gregorianor:hebrew.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.cldr_calendar_type() == Calendrical.Ethiopic.AmeteAlem.info().cldr_calendar_type
true
Returns the CLDR calendar type whose data names a date's months and
days: the member in effect on the date in a composite calendar, and
this calendar's own otherwise (Calendrical.Info.cldr_calendar_type/4).
Arguments
year,monthanddayare a date of this calendar.
Returns
- A CLDR calendar type.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> in_effect = Calendrical.Info.in_effect(Calendrical.Ethiopic.AmeteAlem, date.year, date.month, date.day)
iex> Calendrical.Ethiopic.AmeteAlem.cldr_calendar_type(date.year, date.month, date.day) == in_effect.cldr_calendar_type()
true
Returns the CLDR month of a month of a year
(Calendrical.Month.cldr_month/3).
Arguments
yearandmonthare a month of this calendar.
Returns
A CLDR month number, or
{month, :leap}where the month's name has a leap form, or{:error, exception}for a month the year does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> cldr_month = Calendrical.Ethiopic.AmeteAlem.cldr_month(date.year, date.month)
iex> Calendrical.Ethiopic.AmeteAlem.written_month_from_cldr_month(date.year, cldr_month) ==
...> Calendrical.Ethiopic.AmeteAlem.numeric_month(date.year, date.month, date.day)
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidMonthError{}} = Calendrical.Ethiopic.AmeteAlem.cldr_month(date.year, 99)
Returns the cyclic year of a date (Calendrical.Era.cyclic_year/4).
Arguments
year,monthanddayare a date of this calendar.
Returns
The date's place in the sexagenary cycle,
1to60, in an East Asian calendar, and its year in a calendar whose years run in no such cycle, or{:error, %Calendrical.InvalidDateError{}}for a year the calendar does not have, or{:error, exception}, aCalendrical.MissingFieldsError, for no year.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> cyclic_year = Calendrical.Ethiopic.AmeteAlem.cyclic_year(date.year, date.month, date.day)
iex> cyclic_year in 1..60 or cyclic_year == date.year
true
iex> {:error, %Calendrical.MissingFieldsError{}} = Calendrical.Ethiopic.AmeteAlem.cyclic_year(nil, 1, 1)
Returns the date of this calendar that written figures name
(date_from_written_date/3), as fields.
Arguments
year,monthanddayare the figures a date is written with, aswritten_date/3returns them.
Returns
{year, month, day}, the date of this calendar, or{:error, %Calendrical.InvalidDateError{}}where the figures name no date.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {year, month, day} = Calendrical.Ethiopic.AmeteAlem.written_date(date.year, date.month, date.day)
iex> Calendrical.Ethiopic.AmeteAlem.date_from_cardinal_date(year, month, day) == {date.year, date.month, date.day}
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidDateError{}} = Calendrical.Ethiopic.AmeteAlem.date_from_cardinal_date(date.year, 0, 1)
Returns the date of a day of a year, counted from the year's first day.
Arguments
yearis a year of this calendar.day_of_yearis the day of the year, counted from 1.
Returns
A
Date.t/0of this calendar, or{:error, %Calendrical.InvalidDateError{}}for a day the year does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> day_of_year = Calendrical.Ethiopic.AmeteAlem.day_of_year(date.year, date.month, date.day)
iex> Calendrical.Ethiopic.AmeteAlem.date_from_day_of_year(date.year, day_of_year) == date
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidDateError{}} = Calendrical.Ethiopic.AmeteAlem.date_from_day_of_year(date.year, 1000)
Returns an Amete Alem {year, month, day} tuple for the given
ISO day number.
Arguments
iso_daysis an integer count of days since the proleptic ISO epoch.
Returns
- A three-tuple
{year, month, day}in Amete Alem numbering.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.date_from_iso_days(740_000)
{7518, 5, 11}
Returns the date of a day of a week of a week-year
(Calendrical.Week.date_from_week_date/4).
Arguments
week_yearis a week-year of this calendar.weekis a week of the week-year.dayis the day of the week, numbered from 1 for the day the calendar's weeks begin on.
Returns
A
Date.t/0of this calendar, or{:error, %Calendrical.InvalidDateError{}}where the week has no such day.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {week_year, week, day} = Calendrical.Ethiopic.AmeteAlem.week_date_from_date(date.year, date.month, date.day)
iex> Calendrical.Ethiopic.AmeteAlem.date_from_week_date(week_year, week, day) == date
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidDateError{}} = Calendrical.Ethiopic.AmeteAlem.date_from_week_date(date.year, 1, 8)
Returns the date of this calendar that written figures name: the
inverse of written_date/3, the fields themselves where they are a
date.
Arguments
year,monthanddayare the figures a date is written with, aswritten_date/3returns them.
Returns
{:ok, {year, month, day}}, the date of this calendar, or{:error, :invalid_date}where the figures name no date.
The reason is an atom, not an exception: Localize's date parser reads
it, as Calendrical.date_from_written_date/3 sets out.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {year, month, day} = Calendrical.Ethiopic.AmeteAlem.written_date(date.year, date.month, date.day)
iex> Calendrical.Ethiopic.AmeteAlem.date_from_written_date(year, month, day) == {:ok, {date.year, date.month, date.day}}
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.date_from_written_date(date.year, 0, 1)
{:error, :invalid_date}
Returns the number of ISO days for the given Amete Alem year,
month, and day.
Arguments
yearis any Amete Alem year as an integer.monthis an Ethiopic month in the range1..13.dayis an Ethiopic day-of-month.
Returns
- An integer count of days since the proleptic ISO epoch.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.date_to_iso_days(7518, 1, 1)
739870
Returns the dates of this calendar, earliest first, whose month and day are those given and that fall in a Gregorian year.
Arguments
gregorian_yearis the Gregorian year to search within.monthanddayare a month and a day of this calendar.
Returns
- A list of zero, one or two
Date.t/0of this calendar, earliest first, since this calendar's years and the Gregorian years drift.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> date in Calendrical.Ethiopic.AmeteAlem.dates_in_gregorian_year(2024, date.month, date.day)
true
Returns the days a month of a year has, as runs of their numbers
(Calendrical.Month.day_numbers/3).
Arguments
yearandmonthare a month of this calendar.
Returns
- A list of ranges: one from 1 in every month of every calendar but
a composite, whose month a change of calendar falls in has the
days that are left, and
[]for a month the year does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.day_numbers(date.year, date.month) ==
...> [1..Calendrical.Ethiopic.AmeteAlem.days_in_month(date.year, date.month)//1]
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.day_numbers(date.year, 99)
[]
Returns the day of era and era of a date (Calendrical.Era.day_of_era/4).
Arguments
year,monthanddayare a date of this calendar.
Returns
{day_of_era, era}, where the day of the era counts from the era's first day, or{:error, %Calendrical.InvalidDateError{}}for a date the calendar does not have, or{:error, exception}, aCalendrical.MissingFieldsError, for a missing field.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {day_of_era, era} = Calendrical.Ethiopic.AmeteAlem.day_of_era(date.year, date.month, date.day)
iex> {_year_of_era, year_era} = Calendrical.Ethiopic.AmeteAlem.year_of_era(date.year, date.month, date.day)
iex> day_of_era >= 1 and era == year_era
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidDateError{}} = Calendrical.Ethiopic.AmeteAlem.day_of_era(date.year, date.month, 0)
Returns the day of the week of a date (Calendrical.Week.day_of_week/5).
Arguments
year,monthanddayare a date of this calendar.starting_onis:defaultfor the day this calendar's weeks begin on, or the name of a weekday,:mondayto:sunday.
Returns
{day_of_week, 1, 7}, the day numbered from the day the week begins on, or{:error, %Calendrical.InvalidDateError{}}for a date the calendar does not have, or{:error, exception}, aCalendrical.MissingFieldsError, for a missing field.
Examples
# 1 June 2024 is a Saturday
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.day_of_week(date.year, date.month, date.day, :monday)
{6, 1, 7}
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidDateError{}} = Calendrical.Ethiopic.AmeteAlem.day_of_week(date.year, date.month, 0, :monday)
Returns the day of the year of a date (Calendrical.Period.day_of_year/4).
Arguments
year,monthanddayare a date of this calendar.
Returns
The day of the year, counted from 1 for its first day, or
{:error, %Calendrical.InvalidDateError{}}for a date the calendar does not have, or{:error, exception}, aCalendrical.MissingFieldsError, for a missing field.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> first_day = Calendrical.Ethiopic.AmeteAlem.year(date.year).first
iex> Calendrical.Ethiopic.AmeteAlem.day_of_year(date.year, date.month, date.day) == Date.diff(date, first_day) + 1
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidDateError{}} = Calendrical.Ethiopic.AmeteAlem.day_of_year(date.year, date.month, 0)
Returns the number of days in a month without a year
(Calendrical.Month.days_in_month/2).
Arguments
monthis a month of this calendar.
Returns
The number of days where the month has as many in every year, or
{:ambiguous, lengths}where its length depends on the year, the lengths a range or, where they are not consecutive, a list, or{:error, %Calendrical.NotDefinedError{}}for a month the calendar has in no year, or{:error, exception}, aCalendrical.MissingFieldsError, where the month isnil.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {fewest, most} = Calendrical.Ethiopic.AmeteAlem.days_in_month_bounds(date.month)
iex> case Calendrical.Ethiopic.AmeteAlem.days_in_month(date.month) do
...> days when is_integer(days) -> fewest == days and most == days
...> {:ambiguous, lengths} -> Enum.min(lengths) == fewest and Enum.max(lengths) == most
...> end
true
iex> {:error, %Calendrical.NotDefinedError{}} = Calendrical.Ethiopic.AmeteAlem.days_in_month(99)
@spec days_in_month(Calendar.year(), Calendar.month()) :: Calendar.day() | {:error, Exception.t()}
@spec days_in_month(year(), month()) :: 5..30 | {:error, Exception.t()}
Returns the number of days in the given Amete Alem year and
month.
Months 1-12 always have 30 days; month 13 has 5 days, or 6 in a leap year.
Arguments
yearis any Amete Alem year as an integer.monthis an Ethiopic month in the range1..13.
Returns
An integer number of days, or
{:error, %Calendrical.InvalidMonthError{}}for a month the year does not have, or{:error, %Calendrical.MissingFieldsError{}}where the year or the month isnil.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.days_in_month(7518, 13)
5
iex> Calendrical.Ethiopic.AmeteAlem.days_in_month(7519, 13)
6
Returns the fewest and the most days a month has in any year
(Calendrical.Month.days_in_month_bounds/2).
Arguments
monthis a month of this calendar.
Returns
{fewest, most}, or{:error, exception}for a month the calendar has in no year.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {fewest, most} = Calendrical.Ethiopic.AmeteAlem.days_in_month_bounds(date.month)
iex> Calendrical.Ethiopic.AmeteAlem.days_in_month(date.year, date.month) in fewest..most
true
iex> {:error, %Calendrical.InvalidMonthError{}} = Calendrical.Ethiopic.AmeteAlem.days_in_month_bounds(99)
Returns the number of days in a week.
Returns
7.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.days_in_week()
7
Returns the number of days in a year (Calendrical.Period.days_in_year/2).
Arguments
yearis a year of this calendar.
Returns
The number of days, or
{:error, %Calendrical.InvalidDateError{}}for a year the calendar does not have, or{:error, exception}, aCalendrical.MissingFieldsError, for no year.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.days_in_year(date.year) == Enum.count(Calendrical.Ethiopic.AmeteAlem.year(date.year))
true
iex> {:error, %Calendrical.MissingFieldsError{}} = Calendrical.Ethiopic.AmeteAlem.days_in_year(nil)
Returns the number of whole units between two dates, counted positionally.
Arguments
fromandtoare dates of this calendar as{year, month, day}tuples.date_partis one of:years,:quarters,:months,:weeksor:days.
Returns
The largest number of
date_parts that can be added tofromwithout passingto, negative wheretois beforefrom, or{:error, %Calendrical.InvalidDateError{}}for afromortothe calendar does not have,{:error, %Calendrical.MissingFieldsError{}}for one missing a field, or{:error, %Calendrical.InvalidPartError{}}for adate_partother than the five.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> from = {date.year, date.month, date.day}
iex> Calendrical.Ethiopic.AmeteAlem.diff(from, {date.year + 1, date.month, date.day}, :years)
1
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> later = Date.add(date, 10)
iex> Calendrical.Ethiopic.AmeteAlem.diff({later.year, later.month, later.day}, {date.year, date.month, date.day}, :days)
-10
Returns the epoch of this calendar: the ISO day number of its first day.
Returns
- The epoch as an integer number of days since the ISO epoch.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.epoch() |> is_integer()
true
Returns the CLDR calendar type that names this calendar's eras, as
its info/0 states.
Returns
- A CLDR calendar type such as
:gregorianor:japanese.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.era_calendar_type() == Calendrical.Ethiopic.AmeteAlem.info().era_calendar_type
true
@spec era_offset() :: 5500
Returns the offset (in years) between the Amete Alem (Era of the
World) and the Amete Mihret (Era of Mercy) used by
Calendrical.Ethiopic.
Subtracting this offset from an Amete Alem year yields the corresponding Amete Mihret year.
Returns
- The integer
5500.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.era_offset()
5500
Returns the extended year of a date (Calendrical.Era.extended_year/4).
Arguments
year,monthanddayare a date of this calendar.
Returns
The year numbered without a gap at 0, so that in a calendar with no year 0 the year before 1 is 0, or
{:error, %Calendrical.InvalidDateError{}}for a date the calendar does not have, or{:error, exception}, aCalendrical.MissingFieldsError, for no year.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.extended_year(date.year, date.month, date.day) == date.year
true
iex> {:error, %Calendrical.MissingFieldsError{}} = Calendrical.Ethiopic.AmeteAlem.extended_year(nil, 1, 1)
Returns the static facts about this calendar, as
Calendrical.Info.t/0.
Returns
- A
Calendrical.Info.t/0describing this calendar.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.info().calendar
Calendrical.Ethiopic.AmeteAlem
Returns the ISO 8601 week-year and week of the day a date names
(Calendrical.Week.iso_week_of_year/4).
Arguments
year,monthanddayare a date of this calendar.
Returns
{week_year, week}of ISO 8601, or{:error, exception}for a date the calendar does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.iso_week_of_year(date.year, date.month, date.day)
{2024, 22}
Returns the position of a year's leap month, or nil where the
year has none.
Arguments
yearis a year of this calendar.
Returns
The leap month's position in the year, or
nilwhere the year has no leap month, as for anything but an integer year.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> leap_month = Calendrical.Ethiopic.AmeteAlem.leap_month(date.year)
iex> is_nil(leap_month) or leap_month in 1..Calendrical.Ethiopic.AmeteAlem.months_in_year(date.year)
true
Returns whether the given Amete Alem year is a leap year.
The leap-year rule is that of Calendrical.Ethiopic applied to
the corresponding Amete Mihret year.
Arguments
yearis any Amete Alem year as an integer.
Returns
trueif the year contains 366 days; otherwisefalse.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.leap_year?(7519)
true
iex> Calendrical.Ethiopic.AmeteAlem.leap_year?(7518)
false
Returns the traditional month at a position in a year
(Calendrical.Month.traditional_month/3), or an error for a place
the year does not have.
Arguments
yearandmonthare a month of this calendar.
Returns
The month's traditional number, or
{month, :leap}for a leap month, or{:error, %Calendrical.InvalidMonthError{}}for a month the year does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.lunar_month_of_year(date.year, date.month) ==
...> Calendrical.Ethiopic.AmeteAlem.traditional_month(date.year, date.month)
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidMonthError{}} = Calendrical.Ethiopic.AmeteAlem.lunar_month_of_year(date.year, 99)
Returns the days of a month of a year (Calendrical.Period.month/3).
Arguments
yearandmonthare a month of this calendar.
Returns
A
Date.Range.t/0, or{:error, %Calendrical.InvalidDateError{}}for a month the year does not have, or{:error, exception}, aCalendrical.MissingFieldsError, for a missing year or month.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> date in Calendrical.Ethiopic.AmeteAlem.month(date.year, date.month)
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidDateError{}} = Calendrical.Ethiopic.AmeteAlem.month(date.year, 99)
Returns the position of a traditional month in a year
(Calendrical.Month.month_from_traditional/3).
Arguments
yearis a year of this calendar.traditional_monthis a month's traditional number, or{month, :leap}for a leap month.
Returns
The month's position in the year, or
{:error, exception}where the year has no such month.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> traditional_month = Calendrical.Ethiopic.AmeteAlem.traditional_month(date.year, date.month)
iex> Calendrical.Ethiopic.AmeteAlem.month_from_traditional(date.year, traditional_month) == date.month
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidMonthError{}} = Calendrical.Ethiopic.AmeteAlem.month_from_traditional(date.year, 99)
Returns the months a year has, as runs of their numbers
(Calendrical.Month.month_numbers/2).
Arguments
yearis a year of this calendar.
Returns
- A list of ranges: one from 1 in every year of every calendar but a
composite, whose year a change of calendar falls in has the months
that are left, and
[]for a year the calendar does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.month_numbers(date.year) == [1..Calendrical.Ethiopic.AmeteAlem.months_in_year(date.year)//1]
true
Returns the CLDR month of a month of a year: the index of its name
in this calendar's CLDR data, with {month, :leap} where the name
has a leap form (Calendrical.Month.cldr_month/3).
Arguments
year,monthanddayare a date of this calendar. The year and the day may benil: a month's name needs only the month.
Returns
A CLDR month number, or
{month, :leap}, or{:error, %Calendrical.InvalidDateError{}}for a day the month does not have, or{:error, exception}for a month the year does not have, or aCalendrical.MissingFieldsErrorwhere the month isnil.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.month_of_year(date.year, date.month, date.day) == Calendrical.Ethiopic.AmeteAlem.cldr_month(date.year, date.month)
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidDateError{}} = Calendrical.Ethiopic.AmeteAlem.month_of_year(date.year, date.month, 0)
Returns the number of months in a leap year: the most months a year of this calendar has.
Returns
- A positive integer.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.months_in_leap_year() >= Calendrical.Ethiopic.AmeteAlem.months_in_ordinary_year()
true
Returns the number of months in an ordinary year: the fewest months a year of this calendar has.
Returns
- A positive integer.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.months_in_ordinary_year() <= Calendrical.Ethiopic.AmeteAlem.months_in_leap_year()
true
Returns the number of months in a year without a year: the count
where every year has as many, {:ambiguous, range} where a leap
year has more, and {:error, %Calendrical.NotDefinedError{}} for a composite calendar
(Calendrical.Info.months_in_year/1).
Returns
The number of months where every year has as many, or
{:ambiguous, fewest..most}where a leap year has more, or{:error, %Calendrical.NotDefinedError{}}for a composite calendar, whose boundsmonths_in_year_bounds/0gives.
Examples
iex> case Calendrical.Ethiopic.AmeteAlem.months_in_year() do
...> months when is_integer(months) -> months == Calendrical.Ethiopic.AmeteAlem.months_in_leap_year()
...> {:ambiguous, fewest..most//1} -> {fewest, most} == Calendrical.Ethiopic.AmeteAlem.info().months_in_year
...> {:error, %Calendrical.NotDefinedError{}} -> is_list(Calendrical.Ethiopic.AmeteAlem.info().members)
...> end
true
Returns the number of months in a
given year.
Arguments
yearis the year in this calendar.
Returns
The number of months in the year, as a positive integer, or
{:error, %Calendrical.MissingFieldsError{}}whereyearisnil, or{:error, %Calendrical.InvalidDateError{}}whereyearis no integer.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.months_in_year(date.year) >= date.month
true
Returns the fewest and the most months a year has
(Calendrical.Month.months_in_year_bounds/1).
Returns
{fewest, most}, which in a composite calendar counts the months left in a year a change of calendar falls in.
Examples
iex> {fewest, most} = Calendrical.Ethiopic.AmeteAlem.months_in_year_bounds()
iex> fewest <= Calendrical.Ethiopic.AmeteAlem.months_in_ordinary_year() and
...> most >= Calendrical.Ethiopic.AmeteAlem.months_in_leap_year()
true
Converts ISO days and a day fraction to a naive datetime of this
calendar, as Calendar.naive_datetime_from_iso_days/1 asks.
Arguments
iso_daysis{days, {parts_in_day, parts_per_day}}, a day and a fraction of it.
Returns
{year, month, day, hour, minute, second, microsecond}of this calendar.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {year, month, day, 12, 0, 0, {0, 6}} =
...> Calendrical.Ethiopic.AmeteAlem.naive_datetime_from_iso_days({739403, {43200000000, 86400000000}})
iex> {year, month, day} == {date.year, date.month, date.day}
true
Converts a naive datetime of this calendar to ISO days and a day
fraction, as Calendar.naive_datetime_to_iso_days/7 asks.
Arguments
year,monthanddayare a date of this calendar.hour,minute,secondandmicrosecondare a time of day, the microsecond as{microseconds, precision}.
Returns
{iso_days, {parts_in_day, parts_per_day}}.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.naive_datetime_to_iso_days(date.year, date.month, date.day, 12, 0, 0, {0, 6})
{739403, {43200000000, 86400000000}}
Returns the days of a named month in a year
(Calendrical.Month.named_month/3).
Arguments
yearis a year of this calendar.named_monthis the CLDR month that names the month.
Returns
- A list of
Date.Range.t/0, one for each counted month that carries the name, earliest first, and[]where none does.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> cldr_month = Calendrical.Ethiopic.AmeteAlem.cldr_month(date.year, date.month)
iex> Calendrical.Ethiopic.AmeteAlem.named_month(date.year, cldr_month) |> Enum.any?(&(date in &1))
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.named_month(date.year, 99)
[]
Returns the number a date's month is written with in figures: the
month of its written_date/3.
Arguments
year,monthanddayare a date of this calendar.
Returns
The month of the date's
written_date/3: a month number, or{month, :leap}for a leap month of a lunisolar calendar, or{:error, %Calendrical.InvalidDateError{}}for a date the calendar does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {_year, written_month, _day} = Calendrical.Ethiopic.AmeteAlem.written_date(date.year, date.month, date.day)
iex> Calendrical.Ethiopic.AmeteAlem.numeric_month(date.year, date.month, date.day) == written_month
true
Returns the position in a year of a traditional month
(Calendrical.Month.month_from_traditional/3), as {:ok, month}.
Arguments
yearis a year of this calendar.traditional_monthis a month's traditional number, or{month, :leap}for a leap month.
Returns
{:ok, month}, the month's position in the year, or{:error, %Calendrical.InvalidMonthError{}}for a month or a leap month the year does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> traditional_month = Calendrical.Ethiopic.AmeteAlem.traditional_month(date.year, date.month)
iex> Calendrical.Ethiopic.AmeteAlem.ordinal_month_from_traditional(date.year, traditional_month) == {:ok, date.month}
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidMonthError{}} = Calendrical.Ethiopic.AmeteAlem.ordinal_month_from_traditional(date.year, 99)
Parses a date written in this calendar's own notation.
Arguments
stringis a date writtenYYYY-MM-DD, with a leading-for a year before 1, or, in a calendar of weeks,YYYY-Www-D.
Returns
{:ok, {year, month, day}}, or{:error, :invalid_format}where the text is not in that form or its fields are not digits, or{:error, :invalid_date}where the text names no date of this calendar.
The reason is an atom, not an exception, because Calendar.parse_date/1
requires one: Date.from_iso8601/2 reads it.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.parse_date(Date.to_string(date)) == {:ok, {date.year, date.month, date.day}}
true
iex> Calendrical.Ethiopic.AmeteAlem.parse_date("not a date")
{:error, :invalid_format}
Parses a naive datetime written in this calendar's own notation.
Arguments
stringis a date asparse_date/1reads it, thenTor a space and a time of day.
Returns
{:ok, {year, month, day, hour, minute, second, microsecond}}, or{:error, reason}, such as:invalid_formator:invalid_date, where the text is no such datetime.
The reason is an atom, not an exception, because
Calendar.parse_naive_datetime/1 requires one:
NaiveDateTime.from_iso8601/2 reads it.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.parse_naive_datetime(Date.to_string(date) <> "T12:00:00") ==
...> {:ok, {date.year, date.month, date.day, 12, 0, 0, {0, 0}}}
true
iex> Calendrical.Ethiopic.AmeteAlem.parse_naive_datetime("2024-06-01")
{:error, :invalid_format}
Parses a UTC datetime written in this calendar's own notation.
Arguments
stringis a date asparse_date/1reads it, thenTor a space, a time of day and an offset from UTC,ZorยฑHH:MM.
Returns
{:ok, {year, month, day, hour, minute, second, microsecond}, offset}, the datetime in UTC and the offset in seconds it was written with, or{:error, reason}, such as:invalid_format,:invalid_dateor:missing_offset, where the text is no such datetime.
The reason is an atom, not an exception, because
Calendar.parse_utc_datetime/1 requires one:
DateTime.from_iso8601/2 reads it.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.parse_utc_datetime(Date.to_string(date) <> "T12:00:00Z") ==
...> {:ok, {date.year, date.month, date.day, 12, 0, 0, {0, 0}}, 0}
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.parse_utc_datetime(Date.to_string(date) <> "T12:00:00")
{:error, :missing_offset}
Returns the calendar a date written for this calendar is parsed in,
as its info/0 states.
Returns
- A calendar module.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.parsing_calendar() == Calendrical.Ethiopic.AmeteAlem.info().parsing_calendar
true
Returns the calendars a date written for this calendar may be
written in: the members of a composite calendar, and this calendar
alone otherwise (Calendrical.Info.parsing_calendars/1).
Returns
- A non-empty list of calendar modules, the members of a composite calendar in the order they take effect.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> in_effect = Calendrical.Info.in_effect(Calendrical.Ethiopic.AmeteAlem, date.year, date.month, date.day)
iex> in_effect in Calendrical.Ethiopic.AmeteAlem.parsing_calendars()
true
Returns the number of periods in a year: its months.
Arguments
yearis a year of this calendar.
Returns
- The number of months in the year, as
months_in_year/1returns it.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.periods_in_year(date.year) == Calendrical.Ethiopic.AmeteAlem.months_in_year(date.year)
true
Returns the days of a quadrimester of a year
(Calendrical.Period.quadrimester/3).
Arguments
yearis a year of this calendar.quadrimesteris the quadrimester,1to3.
Returns
A
Date.Range.t/0, or{:error, %Calendrical.InvalidDateError{}}for a quadrimester or a year the calendar does not have, or{:error, %Calendrical.MissingFieldsError{}}where the year or the quadrimester isnil.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.quadrimester(date.year, 1).first == Calendrical.Ethiopic.AmeteAlem.year(date.year).first
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidDateError{}} = Calendrical.Ethiopic.AmeteAlem.quadrimester(date.year, 4)
Returns the days of a quarter of a year (Calendrical.Period.quarter/3).
Arguments
yearis a year of this calendar.quarteris the quarter,1to4.
Returns
A
Date.Range.t/0, or{:error, %Calendrical.InvalidDateError{}}for a quarter or a year the calendar does not have, or{:error, %Calendrical.MissingFieldsError{}}where the year or the quarter isnil.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> quarter = Calendrical.Ethiopic.AmeteAlem.quarter_of_year(date.year, date.month, date.day)
iex> date in Calendrical.Ethiopic.AmeteAlem.quarter(date.year, quarter)
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidDateError{}} = Calendrical.Ethiopic.AmeteAlem.quarter(date.year, 5)
Returns the quarter of the year a date falls in
(Calendrical.Period.quarter_of_year/4).
Arguments
year,monthanddayare a date of this calendar.
Returns
The quarter,
1to4, or{:error, %Calendrical.InvalidDateError{}}for a date the calendar does not have, or{:error, exception}, aCalendrical.MissingFieldsError, for a missing year or month.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.quarter_of_year(date.year, date.month, date.day) in 1..4
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidDateError{}} = Calendrical.Ethiopic.AmeteAlem.quarter_of_year(date.year, date.month, 0)
Returns the days of a semester of a year (Calendrical.Period.semester/3).
Arguments
yearis a year of this calendar.semesteris the semester,1or2.
Returns
A
Date.Range.t/0, or{:error, %Calendrical.InvalidDateError{}}for a semester or a year the calendar does not have, or{:error, %Calendrical.MissingFieldsError{}}where the year or the semester isnil.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.semester(date.year, 1).first == Calendrical.Ethiopic.AmeteAlem.year(date.year).first
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidDateError{}} = Calendrical.Ethiopic.AmeteAlem.semester(date.year, 3)
Returns the date a number of years, quarters, months, weeks or days
on from a date of this calendar, by position, with the traditional
month kept across years and a day the resulting month lacks clamped
to its last day unless clamp: false (Calendrical.Shift.shift/7).
Arguments
year,monthanddayare a date of this calendar.date_partis one of:years,:quarters,:months,:weeksor:days.incrementis the number of units, which may be negative.optionsis a keyword list of options.
Options
:clampis whether a day the resulting month lacks becomes its last day. The default istrue.
Returns
{year, month, day}of this calendar, or{:error, %Calendrical.InvalidDateError{}}whereyear,monthanddayare no date of this calendar, or{:error, %Calendrical.MissingFieldsError{}}where a field isnil.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.shift(date.year, date.month, date.day, :days, 0)
{date.year, date.month, date.day}
Shifts a date by a duration: its years and months together, as
shift/6 adds months, and then its weeks and days.
Arguments
year,monthanddayare a date of this calendar.durationis aDuration.t/0.
Returns
{year, month, day}of this calendar.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {year, month, day} = Calendrical.Ethiopic.AmeteAlem.shift_date(date.year, date.month, date.day, Duration.new!(day: 7))
iex> Date.new!(year, month, day, Calendrical.Ethiopic.AmeteAlem) == Date.add(date, 7)
true
Shifts a naive datetime by a duration: its date as shift_date/4
shifts it, and its time as Calendar.ISO does.
Arguments
year,monthanddayare a date of this calendar.hour,minute,secondandmicrosecondare a time of day, the microsecond as{microseconds, precision}.durationis aDuration.t/0.
Returns
{year, month, day, hour, minute, second, microsecond}of this calendar.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> next_day = Date.add(date, 1)
iex> Calendrical.Ethiopic.AmeteAlem.shift_naive_datetime(date.year, date.month, date.day, 23, 0, 0, {0, 0}, Duration.new!(hour: 2)) ==
...> {next_day.year, next_day.month, next_day.day, 1, 0, 0, {0, 0}}
true
Shifts a time by a duration, as Calendar.ISO does.
Arguments
hour,minute,secondandmicrosecondare a time of day, the microsecond as{microseconds, precision}.durationis aDuration.t/0of time units.
Returns
{hour, minute, second, microsecond}, wrapped around midnight.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.shift_time(23, 0, 0, {0, 0}, Duration.new!(hour: 2))
{1, 0, 0, {0, 0}}
Returns the day of a solar term of a Gregorian year, reckoned at the
place this calendar's info/0 names, or at the Chinese calendar's
meridian, the traditional reference, where it names none.
Arguments
indexis the solar term's number,1(lichun, 315ยฐ of solar longitude) to24, every 15ยฐ on.gregorian_yearis a Gregorian year.
Returns
{:ok, date}, aDate.t/0inCalendrical.Gregorian, or{:error, %Calendrical.InvalidSolarTermError{}}whereindexis not1to24.
Examples
# Qingming, the fifth solar term
iex> Calendrical.Ethiopic.AmeteAlem.solar_term(5, 2025)
{:ok, ~D[2025-04-04 Calendrical.Gregorian]}
iex> Calendrical.Ethiopic.AmeteAlem.solar_term(25, 2025)
{:error, %Calendrical.InvalidSolarTermError{index: 25}}
Returns the traditional number of the month a year's leap month
follows, or nil (Calendrical.Month.traditional_leap_month/2).
Arguments
yearis a year of this calendar.
Returns
The traditional number of the month the leap month follows, or
nilwhere the year has no leap month.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> is_nil(Calendrical.Ethiopic.AmeteAlem.traditional_leap_month(date.year)) ==
...> is_nil(Calendrical.Ethiopic.AmeteAlem.leap_month(date.year))
true
Returns a month of a year as this calendar names it
(Calendrical.Month.traditional_month/3).
Arguments
yearandmonthare a month of this calendar.
Returns
The month's traditional number, or
{month, :leap}for a leap month, or{:error, exception}for a month the year does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.traditional_month(date.year, date.month) ==
...> Enum.at(Calendrical.Ethiopic.AmeteAlem.traditional_months(date.year), date.month - 1)
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidMonthError{}} = Calendrical.Ethiopic.AmeteAlem.traditional_month(date.year, 99)
Returns a year's months in order, named traditionally
(Calendrical.Month.traditional_months/2).
Arguments
yearis a year of this calendar.
Returns
- A list of traditional months, the nth naming the year's nth month,
with
{month, :leap}for a leap month, and[]for a year the calendar does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> length(Calendrical.Ethiopic.AmeteAlem.traditional_months(date.year)) ==
...> Calendrical.Ethiopic.AmeteAlem.months_in_year(date.year)
true
Returns whether the given year, month, and day form a valid
Amete Alem date.
Arguments
yearis any Amete Alem year as an integer.monthis an Ethiopic month in the range1..13.dayis an Ethiopic day-of-month. Months1..12have 30 days; month 13 has 5 days, or 6 in a leap year.
Returns
trueif the date is valid; otherwisefalse.
Examples
iex> Calendrical.Ethiopic.AmeteAlem.valid_date?(7518, 1, 30)
true
iex> Calendrical.Ethiopic.AmeteAlem.valid_date?(7519, 13, 6)
true
iex> Calendrical.Ethiopic.AmeteAlem.valid_date?(7518, 13, 6)
false
Returns the seven days of a week of a year (Calendrical.Week.week/3).
Arguments
yearis a year of this calendar.weekis a week of the year.
Returns
A
Date.Range.t/0of the week's seven days, which may begin in the year before or end in the year after, or{:error, %Calendrical.InvalidDateError{}}for a week the year does not have, or{:error, %Calendrical.MissingFieldsError{}}where the year or the week isnil.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {week_year, week} = Calendrical.Ethiopic.AmeteAlem.week_of_year(date.year, date.month, date.day)
iex> days = Calendrical.Ethiopic.AmeteAlem.week(week_year, week)
iex> {Enum.count(days), date in days}
{7, true}
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidDateError{}} = Calendrical.Ethiopic.AmeteAlem.week(date.year, 0)
Returns the week-year, the week and the day of the week of a date
(Calendrical.Week.week_date_from_date/4).
Arguments
year,monthanddayare a date of this calendar.
Returns
{week_year, week, day_of_week}, the day numbered from the day the calendar's weeks begin on, or{:error, %Calendrical.InvalidDateError{}}for a date the calendar does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {week_year, week, day} = Calendrical.Ethiopic.AmeteAlem.week_date_from_date(date.year, date.month, date.day)
iex> {week_year, week} == Calendrical.Ethiopic.AmeteAlem.week_of_year(date.year, date.month, date.day) and day in 1..7
true
Returns the month and the week of the month a date is in
(Calendrical.Week.week_of_month/4).
Arguments
year,monthanddayare a date of this calendar.
Returns
{month, week}, where the month is the one before or after where the date falls in that month's last or first week, or{:error, exception}for a date the calendar does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {month, week} = Calendrical.Ethiopic.AmeteAlem.week_of_month(date.year, date.month, date.day)
iex> month in (date.month - 1)..(date.month + 1) and week >= 1
true
Returns the week-year and the week of the year a date is in
(Calendrical.Week.week_of_year/4).
Arguments
year,monthanddayare a date of this calendar.
Returns
{week_year, week}, where the week-year is the year before or after where the date falls in that year's last or first week, or{:error, exception}for a date the calendar does not have: aCalendrical.MissingFieldsErrorfor a date missing a field, and aCalendrical.InvalidDateErrorotherwise.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {week_year, week} = Calendrical.Ethiopic.AmeteAlem.week_of_year(date.year, date.month, date.day)
iex> date in Calendrical.Ethiopic.AmeteAlem.week(week_year, week)
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidDateError{}} = Calendrical.Ethiopic.AmeteAlem.week_of_year(date.year, date.month, 0)
Returns the number of weeks in a week-year
(Calendrical.Week.weeks_in_week_year/2).
Arguments
week_yearis a week-year of this calendar.
Returns
The number of weeks, or
{:error, %Calendrical.InvalidDateError{}}for a year the calendar does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {week_year, week, _day} = Calendrical.Ethiopic.AmeteAlem.week_date_from_date(date.year, date.month, date.day)
iex> week <= Calendrical.Ethiopic.AmeteAlem.weeks_in_week_year(week_year)
true
Returns the number of weeks in a year (Calendrical.Week.weeks_in_year/2).
Arguments
yearis a year of this calendar.
Returns
The number of weeks, or
{:error, exception}for a year the calendar does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {week_year, week} = Calendrical.Ethiopic.AmeteAlem.week_of_year(date.year, date.month, date.day)
iex> week <= Calendrical.Ethiopic.AmeteAlem.weeks_in_year(week_year)
true
Returns the weeks of a month of a year in order
(Calendrical.Week.weeks_of_month/3).
Arguments
yearandmonthare a month of this calendar.
Returns
A list of
Date.Range.t/0, one for each weekweek_of_month/3names for the month, the first of which may begin in the month before and the last run into the month after, or{:error, exception}for a month the year does not have.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.weeks_of_month(date.year, date.month) |> Enum.all?(&(Enum.count(&1) == 7))
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidMonthError{}} = Calendrical.Ethiopic.AmeteAlem.weeks_of_month(date.year, 99)
Returns the figures a date is written with: its own fields, in a calendar whose dates are written as its own.
Arguments
year,monthanddayare a date of this calendar.
Returns
{year, month, day}as the date is written, where the month of a lunisolar calendar is its traditional number,{month, :leap}for a leap month.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {year, month, day} = Calendrical.Ethiopic.AmeteAlem.written_date(date.year, date.month, date.day)
iex> Calendrical.Ethiopic.AmeteAlem.date_from_written_date(year, month, day) == {:ok, {date.year, date.month, date.day}}
true
Returns the month a CLDR month is written with in a year
(Calendrical.Month.written_month_from_cldr_month/3).
Arguments
yearis a year of this calendar.cldr_monthis a CLDR month number, or{month, :leap}.
Returns
The month as
written_date/3writes it, or{:error, :invalid_month}where the year has no month of that name. The reason is an atom, not an exception: Localize's date parser reads it, whereCalendrical.Month.written_month_from_cldr_month/3answers with an exception.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {_year, written_month, _day} = Calendrical.Ethiopic.AmeteAlem.written_date(date.year, date.month, date.day)
iex> cldr_month = Calendrical.Ethiopic.AmeteAlem.cldr_month(date.year, date.month)
iex> Calendrical.Ethiopic.AmeteAlem.written_month_from_cldr_month(date.year, cldr_month) == written_month
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.written_month_from_cldr_month(date.year, 99)
{:error, :invalid_month}
Returns the days of a year (Calendrical.Period.year/2).
Arguments
yearis a year of this calendar.
Returns
A
Date.Range.t/0, or{:error, %Calendrical.InvalidDateError{}}for a year the calendar does not have, or{:error, exception}, aCalendrical.MissingFieldsError, for no year.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> date in Calendrical.Ethiopic.AmeteAlem.year(date.year)
true
iex> {:error, %Calendrical.MissingFieldsError{}} = Calendrical.Ethiopic.AmeteAlem.year(nil)
Returns the year of era and era of a year (Calendrical.Era.year_of_era/2).
Arguments
yearis a year of this calendar.
Returns
{year_of_era, era}, the era in effect on the year's first day, or{:error, %Calendrical.InvalidDateError{}}for a year the calendar does not have, or{:error, exception}, aCalendrical.MissingFieldsError, for no year.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> Calendrical.Ethiopic.AmeteAlem.year_of_era(date.year) ==
...> Calendrical.Ethiopic.AmeteAlem.year_of_era(date.year, date.month, date.day)
true
Returns the year of era and era of a date (Calendrical.Era.year_of_era/4).
Arguments
year,monthanddayare a date of this calendar.
Returns
{year_of_era, era}, or{:error, %Calendrical.InvalidDateError{}}for a date the calendar does not have, or{:error, exception}, aCalendrical.MissingFieldsError, for no year.
Examples
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {year_of_era, era} = Calendrical.Ethiopic.AmeteAlem.year_of_era(date.year, date.month, date.day)
iex> year_of_era >= 1 and is_integer(era)
true
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> {:error, %Calendrical.InvalidDateError{}} = Calendrical.Ethiopic.AmeteAlem.year_of_era(date.year, 99, 1)
Returns the number of years after which this calendar's years
repeat, as its info/0 states, or {:error, %Calendrical.NotDefinedError{}}.
Returns
The number of years in the cycle, or
{:error, %Calendrical.NotDefinedError{}}where the calendar states none.
Examples
# A year has as many days as the year one cycle later
iex> {:ok, date} = Date.convert(~D[2024-06-01], Calendrical.Ethiopic.AmeteAlem)
iex> case Calendrical.Ethiopic.AmeteAlem.years_in_cycle() do
...> {:error, %Calendrical.NotDefinedError{}} -> true
...> years -> Calendrical.Ethiopic.AmeteAlem.days_in_year(date.year) == Calendrical.Ethiopic.AmeteAlem.days_in_year(date.year + years)
...> end
true