PHPackages                             nrngajurel/nepali-calendar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. nrngajurel/nepali-calendar

ActiveLibrary

nrngajurel/nepali-calendar
==========================

Bikram Sambat (Nepali) calendar conversion with configurable, tenant-friendly Carbon macros for Laravel.

v1.0.3(today)00MITPHPPHP ^8.1CI failing

Since Jul 23Pushed todayCompare

[ Source](https://github.com/Nrngajurel/nepali-calendar)[ Packagist](https://packagist.org/packages/nrngajurel/nepali-calendar)[ Docs](https://github.com/nrngajurel/nepali-calendar)[ RSS](/packages/nrngajurel-nepali-calendar/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (9)Versions (3)Used By (0)

nrngajurel/nepali-calendar
==========================

[](#nrngajurelnepali-calendar)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bbc99252b432fb8ac06ba5cae706533c021153f7c888df1860b519bda0eb1cbd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e726e67616a7572656c2f6e6570616c692d63616c656e6461722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nrngajurel/nepali-calendar)[![Tests](https://camo.githubusercontent.com/12f15b60430d30807ff78b997acd06554aeaa5d8815b1df1e1cbb59211234abc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e726e67616a7572656c2f6e6570616c692d63616c656e6461722f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/nrngajurel/nepali-calendar/actions/workflows/tests.yml)[![Total Downloads](https://camo.githubusercontent.com/131d6c187b958648e777d65eb85cac091fbb7beb2c95b0348d2af8efae3cbc5b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e726e67616a7572656c2f6e6570616c692d63616c656e6461722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nrngajurel/nepali-calendar)[![License](https://camo.githubusercontent.com/b001f848833fd4dcec9aa266e9e973d04ff54c887eb5d71855a87e292a54491d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e726e67616a7572656c2f6e6570616c692d63616c656e6461722e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

Bikram Sambat (BS) ⇄ Gregorian (AD) date conversion for PHP, with Laravel Carbon macros that respect a **configurable** calendar mode. Storage stays AD; only the *view* layer switches — drop it into any app that needs to show dates in BS, AD, or both.

Contents
--------

[](#contents)

- [Features](#features)
- [Datepicker components](#datepicker-components)
- [Requirements](#requirements)
- [Install](#install)
- [Carbon macros](#carbon-macros)
- [Manager / facade](#manager--facade)
- [Making the mode configurable per tenant / user](#making-the-mode-configurable-per-tenant--user)
- [Framework-agnostic converter](#framework-agnostic-converter)
- [Package layout](#package-layout)
- [Testing](#testing)
- [Changelog](#changelog)
- [Publishing](#publishing)
- [Contributing](#contributing)
- [Security](#security)
- [Credits](#credits)
- [License](#license)

Features
--------

[](#features)

- Pure PHP converter (`NepaliCalendarConverter`) — works outside Laravel too.
- Verified against known Nepali New Year dates and round-trip tested across the entire supported range (BS 1970–2100 / AD 1914–2043) with zero drift.
- Calendar mode ('bs' vs 'ad') is resolved through a `CalendarModeResolver`interface — bind your own for tenant- or user-specific behaviour.
- Throws typed exceptions (`InvalidNepaliDateException`, `UnsupportedDateRangeException`) instead of silently returning `null`.
- Scaffolded to match `laravel package` (Laravel Installer ≥ v5.31.0) — Pest, Pint, Larastan, and a Testbench workbench sandbox, so it's ready for `composer test` / `composer serve` out of the box.

Datepicker components
---------------------

[](#datepicker-components)

This package ships three Blade components that wrap **[nrngajurel/nepali-datepicker-pro](https://github.com/nrngajurel/nepali-datepicker-pro)**(a zero-dependency JS/CSS package, loaded via CDN by default — nothing to `npm install` or `composer require`) out of the box. Each renders an `` using that package's own documented `data-nepali-*` auto-init contract, so you get a working BS/AD picker with zero JavaScript of your own:

```
{{-- Date + time --}}

{{-- Date range --}}

{{-- Month (e.g. payroll/report filter) --}}

```

Date Picker
-----------

[](#date-picker)

   [![Date Picker](https://camo.githubusercontent.com/d3e65799e30f817a1b9c53371e8d400fa162461ac0452052647f525feefd266b/68747470733a2f2f6e6570616c692d646174657069636b65722d70726f2e76657263656c2e6170702f696d616765732f646174652d7069636b65722e706e67)](https://camo.githubusercontent.com/d3e65799e30f817a1b9c53371e8d400fa162461ac0452052647f525feefd266b/68747470733a2f2f6e6570616c692d646174657069636b65722d70726f2e76657263656c2e6170702f696d616765732f646174652d7069636b65722e706e67)
**Date Picker**   [![Date Range Picker](https://camo.githubusercontent.com/7d2568debb97b0e344915fe40278cc03857b2f93e4c8b4082159d62257c0c48b/68747470733a2f2f6e6570616c692d646174657069636b65722d70726f2e76657263656c2e6170702f696d616765732f646174652d72616e67652d7069636b65722e706e67)](https://camo.githubusercontent.com/7d2568debb97b0e344915fe40278cc03857b2f93e4c8b4082159d62257c0c48b/68747470733a2f2f6e6570616c692d646174657069636b65722d70726f2e76657263656c2e6170702f696d616765732f646174652d72616e67652d7069636b65722e706e67)
**Date Range Picker**     [![Date Time Picker](https://camo.githubusercontent.com/7acecb6f8b34f9ec16b714cad2469c1f313bec3eb11345ccb4bdb09847eacbb3/68747470733a2f2f6e6570616c692d646174657069636b65722d70726f2e76657263656c2e6170702f696d616765732f646174652d74696d652d7069636b65722e706e67)](https://camo.githubusercontent.com/7acecb6f8b34f9ec16b714cad2469c1f313bec3eb11345ccb4bdb09847eacbb3/68747470733a2f2f6e6570616c692d646174657069636b65722d70726f2e76657263656c2e6170702f696d616765732f646174652d74696d652d7069636b65722e706e67)
**Date Time Picker**   [![Month Picker](https://camo.githubusercontent.com/d697b0e858ded97e2e4e6dd466bb97dc7c9b4764014e74a54480309021b45ff2/68747470733a2f2f6e6570616c692d646174657069636b65722d70726f2e76657263656c2e6170702f696d616765732f6d6f6e74682d7069636b65722e706e67)](https://camo.githubusercontent.com/d697b0e858ded97e2e4e6dd466bb97dc7c9b4764014e74a54480309021b45ff2/68747470733a2f2f6e6570616c692d646174657069636b65722d70726f2e76657263656c2e6170702f696d616765732f6d6f6e74682d7069636b65722e706e67)
**Month Picker**  ---

```
// Controller
$validated = $request->validate([
    'appointment_date' => 'required|date',
    'stay_range' => 'required|string',   // "2024-04-13,2024-04-20" (AD ISO)
    'report_month' => 'required|string', // "2024-04-13,2024-05-12" (AD ISO)
]);

$appointment->date = Carbon::parse($validated['appointment_date']);
[$rangeStart, $rangeEnd] = explode(',', $validated['stay_range']);
```

The picker you *show* the user (BS, Nepali digits, whatever `displayFormat`you configure on the JS side) is never assumed to be the value you *submit* — `submit-name` injects a hidden field carrying the AD value, exactly like nepali-datepicker-pro's own `submitName` option. See that package's README for the full JS-side option set (min/max dates, disabled weekdays, presets, locale, etc.) — anything not exposed as a Blade prop below is still reachable by adding your own `data-*` attribute or calling the JS API directly on the rendered input's `id`.

ComponentWrapsKey props```NepaliDateTimePicker``name`, `submit-name`, `alt-field`, `with-time`, `time-format` (`12h`/`24h`), `minute-step`, `value-format` (`iso`/`iso-bs`/`timestamp`), `value`, `placeholder`, `required````NepaliDateRangePicker``submit-name`, `alt-field`, `fiscal-start-month`, `value-format`, `value`, `placeholder`, `required````NepaliMonthPicker``submit-name`, `alt-field`, `value-format`, `value`, `placeholder`, `required`Any attribute not listed (`class`, extra `data-*`, `x-model`, etc.) passes straight through to the rendered ``.

Assets (the CDN ``/`` tags plus a single `NepaliPicker.autoInit()`call) are injected once automatically, no matter how many of the three components appear on a page. If you already bundle `nepali-datepicker-pro`yourself via npm, publish the config and set `datepicker.load_assets` to `false` — the components still render the correct markup, they just skip the CDN tags:

```
php artisan vendor:publish --tag=nepali-calendar-config
```

```
// config/nepali-calendar.php
'datepicker' => [
    'load_assets' => true,   // false if you bundle nepali-datepicker-pro yourself
    'cdn_version' => null,   // e.g. '0.2.0' to pin a version; null = latest
],
```

Publish the views if you want to customize the markup:

```
php artisan vendor:publish --tag=nepali-calendar-views
```

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 9, 10, 11, 12, or 13 (via `illuminate/contracts` + `illuminate/support`)
- `nesbot/carbon` ^2.63 or ^3.0

Install
-------

[](#install)

```
composer require nrngajurel/nepali-calendar
```

`nepali-datepicker-pro` itself is a plain npm/JS package — the 3 components above pull it in for you via CDN, so there's nothing extra to install unless you want to bundle it yourself (`npm install nepali-datepicker-pro`).

Laravel auto-discovers the service provider and the `NepaliDate` facade. Publish the config if you want to change defaults:

```
php artisan vendor:publish --tag=nepali-calendar-config
```

```
// config/nepali-calendar.php
return [
    'mode' => env('NEPALI_CALENDAR_MODE', 'ad'),
    'resolver' => \Nrngajurel\NepaliCalendar\Resolvers\ConfigCalendarModeResolver::class,
    'nepali_digits_default' => false,
];
```

Carbon macros
-------------

[](#carbon-macros)

```
use Carbon\Carbon;

$date = Carbon::create(2024, 4, 13);

$date->toBsArray();       // ['year' => 2081, 'month' => 1, 'day' => 1, 'weekday' => 7]
$date->toBs();             // "2081-01-01"                  — always BS, ignores mode
$date->toBs('F j, Y');     // "Baishak 1, 2081"
$date->toBs('F j, Y', 'np'); // "बैशाख 1, 2081"
$date->toBs('Y-m-d', 'en', true); // "२०८१-०१-०१"           — Devanagari digits

$date->display();          // BS or AD string depending on the resolved mode
$date->displayHuman();      // "Baishak 1, 2081" or "Apr 13, 2024"
$date->displayWithDay();    // "Saturday, Baishak 1, 2081" or "..., Apr 13, 2024"
$date->displayNepali();     // "१ बैशाख २०८१"
$date->displayDateTime();   // date (per mode) + time

Carbon::parseDisplay($request->input('date')); // parses BS or AD input back to a real AD Carbon
```

`display()` and friends only affect *presentation*. Keep storing and querying dates in AD — that's what `parseDisplay()` is for: it takes whatever the user typed (or whatever nepali-datepicker-pro submitted) in the currently active calendar and converts it back to AD before you touch the database.

Manager / facade
----------------

[](#manager--facade)

For services, jobs, and Artisan commands where a Carbon instance isn't already in scope:

```
use Nrngajurel\NepaliCalendar\Facades\NepaliDate;

NepaliDate::mode();                 // 'bs' | 'ad'
NepaliDate::isBs();
NepaliDate::toBs($carbonDate);      // BsDate value object
NepaliDate::toAd(2081, 1, 1);       // AdDate value object
NepaliDate::display($carbonDate);   // same as $date->display()

// Force a mode for the rest of this request/process (e.g. one export):
NepaliDate::setMode('bs');
// ...
NepaliDate::resetMode();
```

Or inject `Nrngajurel\NepaliCalendar\NepaliCalendarManager` directly.

Making the mode configurable per tenant / user
----------------------------------------------

[](#making-the-mode-configurable-per-tenant--user)

The default resolver reads a single config value, which is fine for a single-tenant app. For anything more dynamic, bind your own resolver in your own `AppServiceProvider` — the package never touches a global helper:

```
use Nrngajurel\NepaliCalendar\Contracts\CalendarModeResolver;
use Nrngajurel\NepaliCalendar\Resolvers\CallbackCalendarModeResolver;

$this->app->bind(CalendarModeResolver::class, function () {
    return new CallbackCalendarModeResolver(
        fn () => auth()->user()?->calendar_preference ?? tenant()->calendar_type ?? 'ad'
    );
});
```

Or implement `CalendarModeResolver` yourself for anything more involved (caching, request-scoped state, etc.):

```
final class TenantCalendarModeResolver implements CalendarModeResolver
{
    public function __construct(private TenantRepository $tenants) {}

    public function mode(): string
    {
        return $this->tenants->current()->calendar_type; // 'bs' | 'ad'
    }
}
```

Framework-agnostic converter
----------------------------

[](#framework-agnostic-converter)

No Laravel required:

```
use Nrngajurel\NepaliCalendar\Converter\NepaliCalendarConverter;

$converter = new NepaliCalendarConverter();

$bs = $converter->adToBs(2024, 4, 13); // BsDate { year: 2081, month: 1, day: 1, weekday: 7 }
$ad = $converter->bsToAd(2081, 1, 1);  // AdDate { year: 2024, month: 4, day: 13, weekday: 7 }
```

Weekday is 1 (Sunday) .. 7 (Saturday).

### Supported range

[](#supported-range)

- AD input: 1914–2043
- BS input: 1970–2100

Dates outside these ranges throw `UnsupportedDateRangeException`. Structurally invalid dates (e.g. `13/32`, `Feb 30`) throw `InvalidNepaliDateException`.

Package layout
--------------

[](#package-layout)

Scaffolded to match the output of `laravel package nrngajurel/nepali-calendar --config --facade --views` (Laravel Installer ≥ v5.31.0, using `laravel/package-skeleton`) — no routes/migrations/translations, since this package doesn't need them:

```
config/nepali-calendar.php     — publishable config (incl. datepicker asset settings)
resources/views/components/    — the 3 Blade components + shared asset partial
src/View/Components/           — their backing component classes
src/                            — package source (converter, manager, facade, macros)
tests/Pest.php                  — binds Tests\TestCase to every test
tests/TestCase.php              — Testbench TestCase, registers the provider
tests/ArchTest.php              — arch/lint-level rules (strict_types, no dd()/env())
tests/Unit/                     — framework-agnostic: converter, data table, formatter
tests/Feature/                  — Laravel-integrated: macros, resolver, facade, components
workbench/                      — sandbox Laravel app for `composer serve`
testbench.yaml                  — Testbench workbench configuration
pint.json, phpstan.neon.dist    — Pint / Larastan config

```

If you'd rather generate a fresh scaffold yourself and diff it against this repo (e.g. after a future `laravel/package-skeleton` update), run:

```
laravel package nrngajurel/nepali-calendar --config --facade --views \
    --author-name="Narayan Gajurel" \
    --author-email="nrngajurel@gmail.com" \
    --vendor-namespace="Nrngajurel" \
    --class-name="NepaliCalendar"
```

Testing
-------

[](#testing)

```
composer install
composer test        # analyse (Larastan) + lint:check (Pint) + test:unit (Pest)
```

Or individually:

```
vendor/bin/pest --parallel     # test suite only
vendor/bin/pint --test         # style check only
vendor/bin/phpstan analyse     # static analysis only
composer serve                 # boot the workbench sandbox app
```

The test suite includes:

- Round-trip conversion (`AD → BS → AD`) across the full supported range.
- Regression tests against two independently verified Nepali New Year dates (BS 2081-01-01 = 13 Apr 2024, BS 2083-01-01 = 14 Apr 2026).
- Feature tests for the Carbon macros, the resolver contract (including binding a custom resolver), and the facade.
- Feature tests for all 3 datepicker components: correct `data-nepali-*`markup, asset dedup across multiple components on one page, and the `load_assets` config toggle.
- An arch test enforcing `strict_types` and banning `dd()`/`env()`/`exit()`in package source.

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for release history.

Publishing
----------

[](#publishing)

1. Push this repository to GitHub as `nrngajurel/nepali-calendar`.
2. Tag a release matching `CHANGELOG.md`: `git tag v1.0.0 && git push --tags`.
3. On [packagist.org](https://packagist.org), "Submit" the GitHub repo URL.
4. Enable the Packagist GitHub App (or add the webhook it gives you) so future tags auto-publish without a manual "Update" click.
5. `composer require nrngajurel/nepali-calendar` then works anywhere.

Contributing
------------

[](#contributing)

1. Fork and clone the repo.
2. `composer install`
3. Make your change, with a Pest test covering it.
4. `composer test` — must pass (Larastan, Pint, Pest) before opening a PR.
5. Open a PR against `main`. CI (`.github/workflows/tests.yml`) runs the same matrix across PHP 8.1–8.4 and Testbench ^9–^11.

Security
--------

[](#security)

If you discover a security vulnerability, please email  instead of opening a public issue.

Credits
-------

[](#credits)

- [Narayan Gajurel](https://github.com/nrngajurel)
- Datepicker UI powered by [nrngajurel/nepali-datepicker-pro](https://github.com/nrngajurel/nepali-datepicker-pro)

License
-------

[](#license)

MIT © Narayan Gajurel . See [LICENSE.md](LICENSE.md).

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/41640621?v=4)[Narayan Gajurel](/maintainers/Nrngajurel)[@Nrngajurel](https://github.com/Nrngajurel)

---

Top Contributors

[![Nrngajurel](https://avatars.githubusercontent.com/u/41640621?v=4)](https://github.com/Nrngajurel "Nrngajurel (5 commits)")

---

Tags

laraveldatecarboncalendarnepalnepalibikram-sambatBSnrngajurel

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/nrngajurel-nepali-calendar/health.svg)

```
[![Health](https://phpackages.com/badges/nrngajurel-nepali-calendar/health.svg)](https://phpackages.com/packages/nrngajurel-nepali-calendar)
```

###  Alternatives

[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k95.4M320](/packages/laravel-horizon)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k30.2M151](/packages/laravel-cashier)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M136](/packages/laravel-pulse)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M245](/packages/laravel-ai)[moonshine/moonshine

Laravel administration panel

1.3k253.1k86](/packages/moonshine-moonshine)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
