Coder Social home page Coder Social logo

ashkanph / jalali-gregorian-converter Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 6 KB

A Javascript converter for Jalali (Persian, Shamsi, Khorshidi) calendar and Gregorian calendar

License: MIT License

JavaScript 100.00%
jalali-calendar jalali-datetime jalali calendar gregorian-calendar converter khorshidi shamsi unix-timestamp calendar-converter

jalali-gregorian-converter's Introduction

A series of functions for converting unix time to Jalali date-time and converting Jalali date-time to Gregorian and vice versa.

Test

  • After cloning the repository and installing the dependencies, you can use jest or npm run test to test the codes.

Usage

import  { 
            jalaliToGregorian, 
            gregorianToJalali,
            unixTimeToGregorianArray, 
            unixTimeToGregorianString,
            unixTimeToJalaliArray, 
            unixTimeToJalaliString 
        } from "jalali";

console.log(gregorianToJalali([2019, 2, 12]));         // [1397, 11, 23]
console.log(jalaliToGregorian([1397, 11, 16]));        // [2019, 2, 5]

console.log(unixTimeToGregorianArray(1549955188474));  // [2019, 2, 12, 10, 36, 28]
console.log(unixTimeToJalaliArray(1549955188474));     // [1397, 11, 23, 10, 36, 28]

console.log(unixTimeToGregorianString(1549955188474)); // 2019/02/12 10:36:28
console.log(unixTimeToJalaliString(1549955188474));    // 1397/11/23 10:36:28

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.