npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

yazdi-datepicker

v1.1.1

Published

A lightweight, accurate, and zero-dependency Persian (Jalali/Shamsi) calendar date picker with accurate date conversion and intuitive year/month selection flow

Readme

Yazdi DatePicker

npm version License: MIT

A lightweight, accurate, and zero-dependency Persian (Jalali/Shamsi) calendar date picker with accurate date conversion and intuitive year/month selection flow.

Features

Zero Dependencies - No external libraries required 📅 Accurate Date Conversion - Precise Gregorian to Jalali conversion 🎨 Beautiful UI - Modern and user-friendly interface 🔄 Smart Selection Flow - Intuitive year → month → day selection 🔢 Persian Numerals - Optional Persian number display 📱 Mobile Friendly - Responsive design for all devices ⚡ Lightweight - ~12KB minified 🌐 Universal - Works with all modern browsers 🎯 Smart Positioning - Calendar auto-positions to stay in viewport

Installation

Using npm

npm install yazdi-datepicker

Using a CDN

<!-- Development version -->
<script src="https://cdn.jsdelivr.net/npm/yazdi-datepicker/yazdi-datepicker.js"></script>

<!-- Production version (minified) -->
<script src="https://cdn.jsdelivr.net/npm/yazdi-datepicker/yazdi-datepicker.min.js"></script>

Direct Download

Download the latest release from GitHub and include it in your project:

<script src="path/to/yazdi-datepicker.min.js"></script>

Quick Start

HTML

<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
    <meta charset="UTF-8">
    <title>Yazdi DatePicker Example</title>
</head>
<body>
    <input type="text" id="myDatePicker" placeholder="انتخاب تاریخ">

    <script src="yazdi-datepicker.min.js"></script>
    <script>
        const picker = new YazdiDatePicker('#myDatePicker');
    </script>
</body>
</html>

JavaScript (ES6 Modules)

import YazdiDatePicker from 'yazdi-datepicker';

const picker = new YazdiDatePicker('#myDatePicker', {
    format: 'YYYY/MM/DD',
    onSelect: (date) => {
        console.log('Selected date:', date);
    }
});

Node.js / CommonJS

const YazdiDatePicker = require('yazdi-datepicker');

const picker = new YazdiDatePicker('#myDatePicker');

API

Constructor

new YazdiDatePicker(inputElement, options)

Parameters

  • inputElement {string|HTMLElement} - CSS selector or DOM element
  • options {Object} - Configuration options (optional)

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | format | string | 'YYYY/MM/DD' | Date format string | | onSelect | function | null | Callback function when date is selected | | autoClose | boolean | true | Auto-close calendar after date selection |

Methods

setValue(dateString)

Set the datepicker value programmatically.

picker.setValue('1403/07/15');

getValue()

Get the current value of the datepicker.

const currentDate = picker.getValue();
console.log(currentDate); // "1403/07/15"

show()

Programmatically show the calendar.

picker.show();

hide()

Programmatically hide the calendar.

picker.hide();

destroy()

Destroy the datepicker instance and remove all event listeners.

picker.destroy();

Examples

Basic Usage

const picker = new YazdiDatePicker('#birthDate');

With Callback Function

const picker = new YazdiDatePicker('#appointmentDate', {
    onSelect: function(date) {
        console.log('Appointment scheduled for:', date);
        // Send to server, update UI, etc.
    }
});

Custom Date Format

const picker = new YazdiDatePicker('#customDate', {
    format: 'YYYY-MM-DD',
    onSelect: (date) => {
        document.getElementById('output').textContent = date;
    }
});

Keep Calendar Open After Selection

const picker = new YazdiDatePicker('#dateInput', {
    autoClose: false
});

Multiple Date Pickers

const birthDate = new YazdiDatePicker('#birthDate', {
    format: 'YYYY/MM/DD'
});

const appointmentDate = new YazdiDatePicker('#appointmentDate', {
    format: 'YYYY-MM-DD',
    onSelect: (date) => alert('Date selected: ' + date)
});

Set Initial Value

const picker = new YazdiDatePicker('#dateInput');
picker.setValue('1403/01/01');

Dynamic Interaction

const picker = new YazdiDatePicker('#dateInput', {
    onSelect: function(date) {
        // Get Jalali date components
        const parts = date.split('/');
        const year = parts[0];
        const month = parts[1];
        const day = parts[2];

        console.log(`Selected: Day ${day}, Month ${month}, Year ${year}`);
    }
});

// Later in your code
document.getElementById('showBtn').addEventListener('click', () => {
    picker.show();
});

document.getElementById('resetBtn').addEventListener('click', () => {
    picker.setValue('');
});

Date Formats

The format option supports the following tokens:

| Token | Description | Example | |-------|-------------|---------| | YYYY | 4-digit year | 1403 | | MM | 2-digit month | 01 to 12 | | DD | 2-digit day | 01 to 31 |

Format Examples

  • YYYY/MM/DD1403/07/15 (default)
  • YYYY-MM-DD1403-07-15
  • DD/MM/YYYY15/07/1403

Browser Support

Yazdi DatePicker works in all modern browsers:

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)
  • Opera (latest)
  • Mobile browsers (iOS Safari, Chrome Mobile, etc.)

Advanced Features

Leap Year Support

The datepicker accurately handles Jalali leap years using the 128-year cycle algorithm.

// Automatically handles leap years
// Esfand will show 30 days in leap years

Smart Calendar Positioning

The calendar automatically positions itself to stay within the viewport:

  • Opens below the input by default
  • Opens above if no space below
  • Adjusts horizontally to stay on screen
  • Accounts for scrolling

Persian Number Display

Month and year names are displayed in Persian, with Persian numerals:

// Displays: فروردین ۱۴۰۳

Intuitive Selection Flow

User-friendly selection process:

  1. Click on year → Select year from grid
  2. Automatically switches to month selector
  3. Click on month → View calendar
  4. Click on day → Date selected

Development

Building from Source

# Clone the repository
git clone https://github.com/maminyazdi/yazdi-datepicker.git
cd yazdi-datepicker

# Install dependencies
npm install

# Build minified version
npm run build

File Structure

yazdi-datepicker/
├── yazdi-datepicker.js        # Source file
├── yazdi-datepicker.min.js    # Minified production build
├── package.json
├── README.md
├── LICENSE
├── CHANGELOG.md
└── example.html               # Examples and demos

Examples

See example.html for a complete working demo with multiple use cases.

# Open example.html in your browser
open example.html

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Amin Yazdi

Changelog

See CHANGELOG.md for a list of changes.

Support

Acknowledgments

  • Based on accurate Jalali calendar conversion algorithms
  • Inspired by the need for a lightweight, dependency-free Persian datepicker
  • Built with love for the Persian-speaking developer community

Made with ❤️ for Persian developers

If you find this useful, please ⭐ star the repository on GitHub!