# `Calendrical.Reform.Sweden.Transitional`

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.

# `calendar_base`

Identifies whether this calendar is month
or week based.

# `calendar_year`

```elixir
@spec calendar_year(Calendar.year(), Calendar.month(), Calendar.day()) ::
  Calendar.year()
```

Returns the calendar year as displayed
on rendered calendars.

# `cldr_calendar_type`

Defines the CLDR calendar type for this calendar.

This type is used in support of `Calendrical.
localize/3`.

# `cyclic_year`

```elixir
@spec cyclic_year(Calendar.year(), Calendar.month(), Calendar.day()) ::
  Calendar.year()
```

Returns the cyclic year as displayed
on rendered calendars.

# `date_from_iso_days`

```elixir
@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_days` is 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}

# `date_to_iso_days`

```elixir
@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`, `month` and `day` are 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

# `day_of_era`

```elixir
@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.

# `day_of_year`

```elixir
@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`.

# `days_in_month`

```elixir
@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.

# `days_in_month`

```elixir
@spec days_in_month(Calendar.year(), Calendar.month()) :: Calendar.month()
```

Returns how many days there are in the given year
and month.

# `days_in_week`

Returns the number days in a a week.

# `days_in_year`

Returns the number days in a given year.

The year is the number of years since the
epoch.

# `epoch`

# `epoch_day_of_week`

# `extended_year`

```elixir
@spec extended_year(Calendar.year(), Calendar.month(), Calendar.day()) ::
  Calendar.year()
```

Returns the extended year as displayed
on rendered calendars.

# `first_day_of_week`

# `iso_week_of_year`

```elixir
@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}`.

# `last_day_of_week`

# `leap_year?`

```elixir
@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

* `year` is the year to test.

### Returns

* A boolean.

### Examples

    iex> Calendrical.Reform.Sweden.Transitional.leap_year?(1704)
    true

# `month`

Returns a `t:Date.Range.t/0` representing
a given month of a year.

# `month_of_year`

```elixir
@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`.

# `months_in_leap_year`

Returns the number of months in a leap year.

# `months_in_ordinary_year`

Returns the number of months in a normal year.

# `months_in_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).

# `months_in_year`

Returns the number of months in a
given `year`.

# `naive_datetime_from_iso_days`

```elixir
@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.

# `naive_datetime_to_iso_days`

```elixir
@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.

# `periods_in_year`

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.

# `plus`

Adds an `increment` number of `date_part`s
to a `year-month-day`.

`date_part` can be `:years`, `:months`, `:weeks` or `:days`.

# `quarter`

Returns a `t:Date.Range.t/0` representing
a given quarter of a year.

# `quarter_of_year`

```elixir
@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`.

# `related_gregorian_year`

```elixir
@spec related_gregorian_year(Calendar.year(), Calendar.month(), Calendar.day()) ::
  Calendar.year()
```

Returns the related Gregorian year as displayed
on rendered calendars.

Per TR35 this is the Gregorian year in which this
calendar's `year` begins, so it is constant for every
date of the calendar year.

# `valid_date?`

Determines if the `date` given is valid according to
this calendar.

# `week`

Returns a `t:Date.Range.t/0` representing
a given week of a year.

# `week_of_month`

```elixir
@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}`.

# `week_of_year`

```elixir
@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}`.

# `weeks_in_year`

Returns the number of weeks in a
given `year`.

# `year`

Returns a `t:Date.Range.t/0` representing
a given year.

# `year_of_era`

```elixir
@spec year_of_era(Calendar.year()) :: {year :: Calendar.year(), era :: Calendar.era()}
```

Calculates the year and era from the given `year`.

# `year_of_era`

```elixir
@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`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
