Dart
Bikram Sambat dates, conversion, formatting and parsing for Dart 3.6 and newer, and for Flutter on every platform. Pure Dart with no dependencies, including on the web.
- You
import 'package:nepdate/nepdate.dart'. - Tithi, public holidays and events are a separate package,
nepdate_patro(import 'package:nepdate_patro/nepdate_patro.dart'). The core has none of that data.
Install
Section titled “Install”dart pub add nepdatedart pub add nepdate:1.0.0-rc.1 pins this pre-release; dart pub add
nepdate_patro:1.0.0-rc.1 adds the patro.
Quick start
Section titled “Quick start”import 'package:nepdate/nepdate.dart';
final d = NepaliDate.fromBs(2080, 5, 15);d.toString(); // 2080/05/15d.toDateTime(); // 2023-09-01 00:00:00.000Zd.toLongString(weekday: true, lang: Lang.ne); // शुक्रवार, भदौ १५, २०८०NepaliDate.parse('2080/05/15') == d; // trueArithmetic stays on the BS calendar, so month lengths come from the shared data rather than from the Gregorian calendar:
final d = NepaliDate.fromBs(2080, 5, 15);d.addDays(1000); // 2083/02/14d.addMonths(13); // 2081/06/15d.fiscalYear.label(); // 2080/81Tithi, holidays and events
Section titled “Tithi, holidays and events”dart pub add nepdate_patroimport 'package:nepdate/nepdate.dart';import 'package:nepdate_patro/nepdate_patro.dart';
final day = info(NepaliDate.fromBs(2080, 5, 15));day.isPublicHoliday; // trueday.tithi?.english; // Dwitiyaday.events.map((e) => e.english).toList(); // [Saparu (Gaijatra) (Kathmandu Holiday), Ropain Jatra]coverage().start; // 2077/01/01info never throws: a date outside the coverage returns one shared empty CalendarInfo. The data
covers BS 2077-01-01 to 2084-08-20.
What each package exports
Section titled “What each package exports”| Package | Names |
|---|---|
nepdate |
NepaliDate, NepaliDateRange, FiscalYear, DateDiff, Lang, Month, Weekday, DateOrder, Separator, MonthOverflow, Quarter, ErrorKind, NepDateException |
nepdate_patro |
Named, CalendarInfo, info, coverage, publicHolidays |
Reference
Section titled “Reference”| Topic | Where |
|---|---|
| Signatures, defaults and exceptions | docs/API.md |
| Benchmarks against the pub.dev competitor and C# NepDate | docs/benchmarks.md |
| What changed | CHANGELOG.md |
| Source | sanamhub/nepdate-dart |