Bongabdo
A Rust library for converting Gregorian dates to Bengali calendar dates across multiple regional standards.
This crate supports:
- the current official Bangladesh civil calendar
- the older Bangladesh revised calendar
- the traditional West Bengal solar calendar
It is designed for cases where Bengali dates differ by region and where "today" should respect the local civil day in Dhaka or Kolkata rather than a UTC day boundary.
Supported Standards
CalendarStandard::BangladeshCurrent official Bangladesh civil calendar after the 2019 revision.CalendarStandard::BangladeshLegacyEarlier Bangladesh fixed calendar adopted in 1987.CalendarStandard::WestBengalTraditionalTraditional West Bengal solar calendar modeled from sidereal solar ingress.
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Quick Start
use ;
Choosing A Standard
Use CalendarStandard::Bangladesh when you want the current official Bangladesh civic calendar.
use ;
let date = from_ymd?;
assert_eq!;
# Ok::
Use CalendarStandard::BangladeshLegacy when you need compatibility with the older Bangladesh revised calendar.
use ;
let date = from_ymd?;
assert_eq!;
# Ok::
Use CalendarStandard::WestBengalTraditional when you want the traditional solar calendar used in West Bengal and commonly in India-facing Bengali date contexts.
use ;
let date = from_ymd?;
assert_eq!;
# Ok::
Parsing BD, WB, IN, And Other Aliases
CalendarStandard implements FromStr, so you can accept string input in your own API and map it into a strongly typed standard.
use CalendarStandard;
let bd: CalendarStandard = "BD".parse?;
let legacy: CalendarStandard = "BD_LEGACY".parse?;
let wb: CalendarStandard = "WB".parse?;
let india: CalendarStandard = "IN".parse?;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
# Ok::
These aliases are supported:
BD,BANGLADESH,BANGLADESH_MODERN,BD_MODERNBD_LEGACY,BANGLADESH_LEGACY,BANGLADESH_1987WB,WEST_BENGAL,WESTBENGAL,WEST_BENGAL_TRADITIONALIN,INDIA,INDIAN_BENGALI,INDIA_BENGALI
Converting Explicit Gregorian Dates
Bongabdo::from_ymd(...) is the most deterministic API in the crate.
use ;
let date = from_ymd?;
assert_eq!;
assert_eq!;
assert_eq!;
# Ok::
This is the best choice when:
- you already have a Gregorian date
- you want reproducible behavior in tests
- you do not want any dependence on the current machine clock
Converting The Current Date
Bongabdo::today(...) computes the Bengali date for the current local civil day of the chosen standard.
- Bangladesh standards use the current Dhaka civil offset,
UTC+06:00 - West Bengal uses the current Kolkata civil offset,
UTC+05:30
This is a fixed-offset model. The crate does not currently use IANA timezone database history for timestamp conversion.
use ;
let today_bd = today?;
let today_wb = today?;
assert_eq!;
assert_eq!;
# Ok::
Converting From SystemTime
If you already have a fixed timestamp, use Bongabdo::from_system_time(...).
use ;
use ;
let timestamp = UNIX_EPOCH + from_secs;
let wb = from_system_time?;
assert_eq!;
# Ok::
This is useful for:
- backend services with timestamp-based data
- tests around local date rollover
- replaying historical conversions from stored timestamps
This is not a timezone-history-accurate API. It applies the current civil offset for the chosen standard rather than full timezone database rules.
Accessing Date Fields
Each Bongabdo value gives you direct access to the computed components.
use ;
let date = from_ymd?;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
# Ok::
Weekday numbering is:
0 = Sunday1 = Monday2 = Tuesday3 = Wednesday4 = Thursday5 = Friday6 = Saturday
Month And Weekday Names
You can access both Bengali-script and Roman-script names.
use ;
let date = from_ymd?;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
# Ok::
Formatting
Bengali Output
Use to_bengali_string() when you want Bengali digits and Bengali script.
use ;
let date = from_ymd?;
assert_eq!;
# Ok::
Roman Output
Use to_roman_string() when you want Roman-script month and weekday names.
use ;
let date = from_ymd?;
assert_eq!;
# Ok::
Display And Standard to_string()
Bongabdo implements Display, so the standard Rust ToString::to_string() output is the Roman-script form.
use ;
let date = from_ymd?;
assert_eq!;
assert_eq!;
# Ok::
Error Handling
Invalid Gregorian input returns BongabdoError::InvalidGregorianDate.
use ;
let result = from_ymd;
assert_eq!;
Parsing an unsupported alias returns an error from FromStr.
use CalendarStandard;
assert!;
Backwards Compatibility
Bongabdo::now() is still available for compatibility with older versions of the crate, but it is intentionally deprecated because it is ambiguous. It currently maps to CalendarStandard::BangladeshLegacy.
For new code, prefer:
Bongabdo::today(CalendarStandard::Bangladesh)Bongabdo::today(CalendarStandard::BangladeshLegacy)Bongabdo::today(CalendarStandard::WestBengalTraditional)
Notes
WBandINare aliases for the same traditional solar standard.- West Bengal support is implemented as a separate traditional solar calculation, not as a one-day offset from Bangladesh.
- The West Bengal path is modeled from sidereal solar ingress. For exact archival or panjika-grade historical work, verify important boundaries against an authoritative published panjika.
from_ymd(...)is the best API for deterministic conversions.today(...)andfrom_system_time(...)use fixed current civil offsets, not historical timezone database rules.today(...)andfrom_system_time(...)are appropriate when present-day "current day" or timestamp-based behavior matters.
Features
- Convert explicit Gregorian dates with
Bongabdo::from_ymd(...) - Convert the current local date with
Bongabdo::today(...) - Convert timestamps with
Bongabdo::from_system_time(...) - Parse
BD,WB,IN, and related aliases intoCalendarStandard - Support Bangladesh modern, Bangladesh legacy, and West Bengal traditional standards
- Format dates in Bengali and Roman script
- Access individual date components, month names, and weekday names
License
This project is licensed under the MIT License. See LICENSE for details.