Kantoor.Contacts.Birthday (Kantoor v1.0.0)

A contact's birthday (vCard BDAY, RFC 6350 section 6.2.5; RFC 2426 section 3.1.5 for vCard 3.0), with or without a year.

Clients write it in several forms and all are read:

  • 19850412 and 1985-04-12 (a date, basic and extended ISO 8601);
  • --0412 and --04-12 (month and day, vCard 4 style, no year);
  • a date-time such as 19850412T000000Z or 1985-04-12T23:30:00-04:00: the date as written is the birthday, the time and offset are ignored;
  • 1604-04-12 with the parameter X-APPLE-OMIT-YEAR=1604, which is how Apple's Contacts writes a birthday whose year is not known into a 3.0 card.

Writing follows the card's own version (line/2). BDAY values the page does not change are kept as written by Kantoor.Contacts; this module only reads and writes what the user edited.

Summary

Functions

The value for a date picker (YYYY-MM-DD); a leap year stands in when there is none.

The content line for the card version, 3.0 or 4.0: BDAY by default, or the property name (ANNIVERSARY uses the same date forms).

Reads a BDAY value. params are the property's parameters (a list of {name, [value]} as Dav.Card.VCard gives them, or a map). :error when the text is not a date.

The birthday as shown, e.g. 12 Apr 1985, or 12 Apr without a year.

Types

t()

@type t() :: %Kantoor.Contacts.Birthday{
  day: 1..31,
  month: 1..12,
  year: integer() | nil
}

Functions

input_value(b)

@spec input_value(t()) :: String.t()

The value for a date picker (YYYY-MM-DD); a leap year stands in when there is none.

line(birthday, version, name \\ "BDAY")

@spec line(t(), String.t(), String.t()) :: String.t()

The content line for the card version, 3.0 or 4.0: BDAY by default, or the property name (ANNIVERSARY uses the same date forms).

parse(text, params \\ [])

@spec parse(String.t(), list() | map()) :: {:ok, t()} | :error

Reads a BDAY value. params are the property's parameters (a list of {name, [value]} as Dav.Card.VCard gives them, or a map). :error when the text is not a date.

text(b)

@spec text(t()) :: String.t()

The birthday as shown, e.g. 12 Apr 1985, or 12 Apr without a year.