Giter Club home page Giter Club logo

jalaliday's Introduction

Jalaliday

npm (scoped with tag) npm CircleCI Codecov Dependencies js-standard-style

Persian (Jalali, Khorshidi) Plugin for Day.js, Jalaliday add multi-calendar functionality to Day.js core regardless for of locale, so we can have Gregorian calendar is Persian locale of Jalali calendar in English locale
Unlike moment and becuase of immutablity of dayjs, there is no need for formats like jYYYY or jMM, in Jalaliday all formats are same and standard

📖 Release Notes

Installation

NPM

npm install --save jalaliday

YARN

yarn add jalaliday

Usage

import dayjs from 'dayjs'
import jalaliday from 'jalaliday'

dayjs.extend(jalaliday)

Changing calendar

If you want to all new instanses of dayjs use jalali calendar, you can set default calendar

dayjs.calendar('jalali') // Jalali Calendar
// OR
dayjs.calendar('gregory') // Gregorian Calendar

also you can create a jalali date without changing default calendar

const date = dayjs()
const jalaliDate = date.calendar('jalali')

Parse Date

  • Parse Gregory date
const date = dayjs('2018-04-04T16:00:00.000Z');
  • Parse Jalali date
const date = dayjs('1398-10-17', { jalali: true });

Multiple Locale

with combination of calendar and locale we have multi language for real

dayjs().calendar('jalali').locale('en').format('DD MMMM YYYY') // '13 Shahrivar 1397'
dayjs().calendar('gregory').locale('fa').format('DD MMMM YYYY') // '04 سپتامبر 2018'

API

All Api operations of Jalaliday is same as Dayjs itself but calendar based, for more information checkout Dayjs API For a glance:

jalaliday's People

Contributors

farnabaz avatar dependabot[bot] avatar mpourismaiel avatar alimo avatar farzadso avatar sasanfarrokh avatar rezahaidari avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.