Quick start
Pick your language. The tab you choose here is remembered on every page with the same tabs.
1. Install the core
Section titled “1. Install the core”cargo add nepdate@=0.1.0-beta.1go get github.com/sanamhub/nepdate-go@v0.1.0-beta.1npm install nepdate-core@betapip install --pre nepdate-core.package(url: "https://github.com/sanamhub/nepdate-swift", exact: "0.1.0-beta.1")implementation("io.github.sanamhub:nepdate:0.1.0-beta.1")FetchContent_Declare(nepdate GIT_REPOSITORY https://github.com/sanamhub/nepdate-cpp.git GIT_TAG v0.1.0-beta.1)dotnet add package NepDate --version 2.0.7The core has no dependencies and no almanac data. Add the patro package later if you need tithi, holidays or events (Core and patro). C# NepDate is one package with both.
2. Convert a date
Section titled “2. Convert a date”Each snippet turns BS 2081-04-15 into AD 2024-07-30 and writes it the long way, Shrawan 15, 2081.
use nepdate::{Lang, LongDate, NepaliDate};
let date = NepaliDate::new(2081, 4, 15)?;let ad = date.to_gregorian();assert_eq!((ad.year(), ad.month(), ad.day()), (2024, 7, 30));println!("{}", date.long(LongDate::default(), Lang::En)); // Shrawan 15, 2081d, err := nepdate.New(2081, nepdate.Shrawan, 15)if err != nil { log.Fatal(err)}y, m, day := d.Gregorian()fmt.Println(y, int(m), day) // 2024 7 30fmt.Println(d.Format("MMMM d, yyyy", nepdate.English)) // Shrawan 15, 2081import { NepaliDate } from "nepdate-core";
const date = NepaliDate.of(2081, 4, 15);date.toGregorian(); // { year: 2024, month: 7, day: 30 }date.long(); // "Shrawan 15, 2081"from nepdate import NepaliDate
date = NepaliDate(2081, 4, 15)date.to_date() # datetime.date(2024, 7, 30)date.long() # 'Shrawan 15, 2081'import NepDate
let date = try NepaliDate(year: 2081, month: 4, day: 15)print(date.gregorian) // (year: 2024, month: 7, day: 30)print(date.long()) // Shrawan 15, 2081val date = NepaliDate.of(2081, 4, 15)println("${date.gregorianYear}-${date.gregorianMonth}-${date.gregorianDay}") // 2024-7-30println(date.toLongString()) // Shrawan 15, 2081#include <nepdate/nepdate.hpp>
const nepdate::date d = nepdate::make_date(2081, 4, 15).value();const auto ad = d.to_year_month_day(); // 2024-07-30std::cout << nepdate::to_string(d); // 2081/04/15using NepDate;
var date = new NepaliDate(2081, 4, 15);Console.WriteLine(date.EnglishDate.ToString("yyyy-MM-dd")); // 2024-07-30Console.WriteLine(date.ToLongDateString()); // Shrawan 15, 20813. Go further
Section titled “3. Go further”Each language page has the full install, formatting and parsing in that language’s style, and the patro:
The behaviour behind every port is described once:
- The Bikram Sambat calendar: range, month lengths and what “today” means.
- Formatting and parsing: the patterns and input every port accepts.