Elixir v1.3.3 Calendar behaviour View Source

This module defines the responsibilities for working with calendars, dates, times and datetimes in Elixir.

Currently it defines types and the minimal implementation for a calendar behaviour in Elixir. The goal of the Calendar features in Elixir is to provide a base for interoperatibility instead of full-featured datetime API.

For the actual date, time and datetime structures, see Date, Time, NaiveDateTime and DateTime.

Note the year, month, day, etc designations are overspecified (i.e. an integer instead of 1..12 for months) because different calendars may have a different number of days per month, months per year and so on.

Link to this section Summary

Types

A calendar implementation

Microseconds with stored precision

From 0 to 60 to account for leap seconds

The time zone standard offset in seconds (not zero in summer times)

The time zone ID according to the IANA tz database (e.g. Europe/Zurich)

The time zone UTC offset in seconds

The time zone abbreviation (e.g. CET or CEST or BST etc.)

Callbacks

Builds a new date from proleptic year, month and day of month

Returns true if the given year is a leap year

Converts the given structure into a string according to the calendar

Link to this section Types

Link to this type calendar() View Source
calendar() :: module

A calendar implementation

Link to this type day() View Source
day() :: integer
Link to this type hour() View Source
hour() :: 0..23
Link to this type microsecond() View Source
microsecond() :: {0..999999, 0..6}

Microseconds with stored precision.

The precision represents the number of digits that must be used when representing the microseconds to external format. If the precision is 0, it means microseconds must be skipped.

Link to this type minute() View Source
minute() :: 0..59
Link to this type month() View Source
month() :: integer
Link to this type second() View Source
second() :: 0..60

From 0 to 60 to account for leap seconds

Link to this type std_offset() View Source
std_offset() :: integer

The time zone standard offset in seconds (not zero in summer times)

Link to this type time_zone() View Source
time_zone() :: String.t

The time zone ID according to the IANA tz database (e.g. Europe/Zurich)

Link to this type utc_offset() View Source
utc_offset() :: integer

The time zone UTC offset in seconds

Link to this type year() View Source
year() :: integer
Link to this type zone_abbr() View Source
zone_abbr() :: String.t

The time zone abbreviation (e.g. CET or CEST or BST etc.)

Link to this section Callbacks

Link to this callback date(year, month, day) View Source
date(year, month, day) :: {:ok, Date.t} | {:error, atom}

Builds a new date from proleptic year, month and day of month.

Link to this callback leap_year?(year) View Source
leap_year?(year) :: boolean

Returns true if the given year is a leap year.

A leap year is a year of a longer length than normal. The exact meaning is up to the calendar. A calendar must return false if it does not support the concept of leap years.

Converts the given structure into a string according to the calendar.