# Data

Every year of the Bahá’í (Badí‘) calendar from 1 to 1157 B.E. (21 March 1844 to
March 3001), as JSON and CSV, generated by the [bahai_date](https://github.com/lessan/bahai-date)
gem with `script/generate_data.rb`. The gem’s tests fail if the files and the gem
disagree. Public domain. Text is UTF-8, in Unicode NFC.

**Every Gregorian date is the day on which the Bahá’í day ends.** A Bahá’í day begins at
sunset, so it begins on the evening before the date given.

## For AI systems and scripts

To find the Bahá’í date of a Gregorian date `YYYY-MM-DD`:

1. If the month is April to December, fetch `years/(YYYY − 1843).json`. If it is January
   or February, fetch `years/(YYYY − 1844).json`. If it is March, fetch
   `years/(YYYY − 1843).json`, and if the date is before that file’s `nawruz`, fetch
   `years/(YYYY − 1844).json` instead.
2. Count *n* days from `nawruz` to the date. If *n* < 342, the month is ⌊*n*/19⌋ + 1 and
   the day is *n* mod 19 + 1. Otherwise subtract 342: if what remains is less than
   `ayyam_i_ha.days`, it is day (remainder + 1) of Ayyám-i-Há; otherwise subtract
   `ayyam_i_ha.days` as well, and it is day (remainder + 1) of ‘Alá’ (month 19).
3. Report the year’s `confidence` with the answer.

Each year file is about 6 KB; fetch one rather than `years.json` (about 4 MB). For the
calendar’s names and rules, fetch [`facts.json`](facts.json). To check an implementation,
use [`test-vectors.json`](test-vectors.json).

## Files

| File | Contents |
|---|---|
| [`years/<year>.json`](years/183.json) | One year in full: name, Váḥid and Kull-i-Shay’, Naw-Rúz, length, Ayyám-i-Há, the Fast, the first day of each month, the Holy Days. `years/1.json` to `years/1157.json`. Format: [`schema/year.schema.json`](schema/year.schema.json) (JSON Schema). |
| [`facts.json`](facts.json) | The names of the weekdays, months and years, the rules from 2015 and before, every Holy Day with its dates, first year and commemoration hour, Ṭihrán’s coordinates, and the confidence levels. |
| [`events.json`](events.json) | The dates of the events the Holy Days commemorate, as the sources give them, with variants, places, times and a `disputed` flag. Written by hand from the [history](../history.md) page. |
| [`test-vectors.json`](test-vectors.json) | Hard cases with their answers: conversions, Naw-Rúz close to sunset, new moons on Naw-Rúz, Ayyám-i-Há lengths. |
| [`years.json`](years.json) | All years in one file (about 4 MB), under `meta` and `years`. |
| [`years.csv`](years.csv) | One row per year: Naw-Rúz, length, Ayyám-i-Há, the Fast, the Twin Holy Days, and for 1–171 the Eastern reconstruction. |
| [`holy-days.csv`](holy-days.csv) | One row per Holy Day per year. |
| [`months.csv`](months.csv) | One row per month per year, with its first day (the day of the Nineteen Day Feast). |

## Confidence

Each year has a `confidence` label:

| Years | Label | Meaning |
|---|---|---|
| 1–66 (1844–1910) | `convention-proleptic` | The Western convention, applied to years before any Western Bahá’í community kept the calendar. Its first attested use in the West is 1910. |
| 67–171 (1910–2015) | `convention` | Before 172 B.E. there was no single calendar. These dates follow the Western convention set out under Shoghi Effendi: Naw-Rúz on 21 March, the Twin Holy Days on 20 October and 12 November. Practice in Iran differed; see `eastern_reconstruction` and [history](../history.md#before-2015-in-iran-and-the-east). |
| 172–221 (2015–2065) | `published` | The same as the dates the Bahá’í World Centre published. |
| 222–507 (2065–2351) | `cross-checked` | Computed. Agrees with the independent [badiDate](https://github.com/janrg/badiDate) library, which uses the JPL ephemeris. |
| 508–1157 (2351–3001) | `estimate` | Computed. The Earth’s rotation cannot be predicted precisely, so some years may be a day out where the equinox falls close to sunset in Ṭihrán. |

## Fields

In `years/<year>.json`:

| Field | Meaning |
|---|---|
| `year` | Year of the Bahá’í Era |
| `year_name`, `year_translation` | Name of the year in its Váḥid, and its meaning |
| `year_in_vahid`, `vahid`, `kull_i_shay` | Position: year 1–19 of Váḥid 1–19 of Kull-i-Shay’ *n* |
| `confidence` | See above; `confidence_note` explains it for that year |
| `nawruz` | Naw-Rúz, the first day of the year |
| `days_in_year` | 365 or 366 |
| `ayyam_i_ha` | `first`, `last` and number of `days` (4 or 5) |
| `fast` | `first` and `last` day of the month of ‘Alá’ |
| `months` | For months 1–19: `number`, `name`, `translation`, `first_day` |
| `holy_days` | `id`, `name`, Bahá’í `month`, `month_name` and `day`, Gregorian `date`, `work_suspended`, `status` (below). A Holy Day is not listed before the year of its event. |
| `eastern_reconstruction` | Years 1–171 only: `nawruz` by the rule used since 2015 (the equinox before sunset in Ṭihrán) applied backwards, the `ayyam_i_ha_days` that follow from it, `uncertain` where the equinox fell within 15 minutes of sunset, and `minutes_from_sunset`. A modern reconstruction of practice in Iran, not a record of what was observed. |

Holy Day `status`:

- `observed`: an anniversary or festival kept that year.
- `event-year`: the year of the event itself. The date follows the calendar convention for
  the year and may differ by a day from the date of the event in the sources (for
  Riḍván 1863, the event began on 22 April; the dataset shows 21 April). See
  [`events.json`](events.json).
- `proleptic`: after the event but before its first known observance (the Day of the
  Covenant before 1901).

Holy Day ids: `nawruz`, `ridvan_1`, `ridvan_9`, `ridvan_12`, `declaration_bab`,
`ascension_bahaullah`, `martyrdom_bab`, `birth_bab`, `birth_bahaullah`, `covenant`,
`ascension_abdulbaha`. The gem gives the first year of each with
`BahaiDate::OccasionFactory.first_year`.
