Badíʿ Noda Time

Badíʿ Noda Time provides functionality for working with Badíʿ Calendar dates in .NET.

View on GitHub View on NuGet

About the Calendar

The Badíʿ calendar was introduced by the founders of the Bahá'í Faith, the Báb and Bahá'u'lláh, in the mid- to late-1800's (of the Gregorian calendar). More details can be found at this Wikipedia page: Badíʿ Calendar.

Installation

You can install this via nuget at NuGet: Badi Noda Time .

Usage

Using

using BadiNodaTime;

Basic Dates

BadiNodaTime has complete support for translating dates between the Badíʿ calendar and the Gregorian calendar. Internally, Noda Time LocalDates with the `CalendarSystem.Badi` are used. If you use LocalDates, the full power of Noda Time is available to you. If you are not using Noda Time, you don't need to know anything about it!

  // show today's date
  var today = new BadiDate();
  Console.WriteLine("Today is " + today.ToString());
  // sample result: Today is 174-15-9

  // convert a Badíʿ date to a Gregorian date
  var gregorianDate = today.DateTime;

  // create a BadiDate from a .NET DateTime
  var date1 = new BadiDate(DateTime.Today);

  // create a BadiDate from a Noda Time LocalDate
  var localDate = new LocalDate(DateTime.Today);
  var date2 = new BadiDate(localDate);

  // create a BadiDate for a specific date
  var date3 = new BadiDate(175, 1, 1); // Naw Ruz 175
  // subtract one day then get the Gregorian date
  var gregorianDate2 = date3.PlusDays(-1).DateTime;
  Console.WriteLine("The day before Naw Rúz 175 is " + gregorianDate2.ToString("D"))
  // sample result: The day before Naw Rúz 175 is Tuesday, March 20, 2018
  

Bahá'í Holy Days

This version of the library has full knowledge of the Bahá'í Holy Days and what days they fall on.

  var year174 = new BadiYearInfo(174);
  var listing = year174.GetSpecialDays(SpecialDayType.HolyDay_WorkSuspended | SpecialDayType.FeastDay);

  // more samples to come...
  

Date Formatting

The `ToString` method of each `BadiDate` object supports a non-standard extended formatting system. The `patternText` you supply is actually a template with a set of custom tokens that will be processed using that date.

  var pattern =  "{day} {month_arabic} {yearOfEra}";
  Console.Writeline(new BadiDate(180, 10, 9).ToString(pattern));
  // result: 9 `Izzat 180

  pattern = "{day_meaning} {month_meaning} {yearOfUnity}";
  // result: Names Might 9

  pattern = "{weekday_arabic}/{weekday_meaning} ({element_meaning}) in the {yearOfUnity_ordinal} year of the {unity_ordinal} Unity.";
  // result: Jalál/Glory (Water) in the nineth year of the tenth Unity.
  

A current list of the tokens supported can be obtained by reading `new BadiNodaTime.Utility.DateTemplateProcessor().AvailableTokens`. Here's a sample for 11 Questions 174:

{day}
11
{day00}
11
{day_ordinal}
eleventh
{day_meaning}
Will
{day_arabic}
Mashíyyat
{weekday}
6
{weekday00}
06
{weekday_ordinal}
sixth
{weekday_meaning}
Majesty
{weekday_arabic}
Istijlál
{month}
15
{month00}
15
{month_ordinal}
fifteenth
{month_meaning}
Questions
{month_arabic}
Masá'il
{element}
4
{element00}
04
{element_meaning}
Earth
{yearOfEra}
174
{yearOfEra00}
174
{yearOfUnity}
3
{yearOfUnity00}
03
{yearOfUnity_ordinal}
third
{yearOfUnity_meaning}
Father
{yearOfUnity_arabic}
Ab
{unity}
10
{unity00}
10
{unity_ordinal}
tenth
{allThings}
1
{allThings00}
01
{allThings_ordinal}
first
{gregorian.day}
21
{gregorian.day00}
21
{gregorian.month}
12
{gregorian.month00}
12
{gregorian.month_latin_short}
Dec
{gregorian.month_latin_long}
December
{gregorian.year}
2017

The names used can be extended into your spoken language quite easily. Languages already in the package include: English, French, German, Dutch, Spanish, Portugese, Chinese, Esperanto, and Tamil. (Some are only partially translated.) For example, in German:

{day_meaning}
Wille
{month_meaning}
Fragen

Road Map

  • Add time and sunset support. The current system ignores sunset and works as if the day starts at midnight.
  • Improve .NET Core specific coding around dependency injection.

Feedback

Please contact Glen Little (glen.little@gmail.com) to discuss any improvements or additions that you might be interested in!