Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shamsi-date-converter

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shamsi-date-converter

A minimal Jalali to Gregorian and Gregorian to Jalali converter

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.6K
decreased by-7.09%
Maintainers
1
Weekly downloads
 
Created
Source

shamsi-date-converter

A Jalali to Gregorian and Gregorian to Jalali converter with no dependency!

MIT License NPM version Codacy Badge

How to

This plugin convert jalali to gregorian and gregorian to jalali in the most simple way

Convert gregorian to jalali

shamsi.gregorianToJalali(1989, 1, 24); //[1367, 11, 4]
// OR
shamsi.gregorianToJalali('July 17, 1995 03:24:00'); //[1374, 4, 26]
// OR
const date = new Date('July 17, 1995 03:24:00');
shamsi.gregorianToJalali(date); //[1374, 4, 26]

Convert jalali to gregorian

shamsi.jalaliToGregorian(1367, 11, 4); //[1989, 1, 24]

Install

Install via npm

npm install shamsi-date-converter -S

Install via yarn

yarn add shamsi-date-converter

Using in Node.js

Install it via npm or yarn then use it as the following code

var shamsi = require('shamsi-date-converter');
shamsi.gregorianToJalali('July 17, 1995 03:24:00'); //[1374, 4, 26]

Using in browser

ES5

get library using bower, npm, cdn, or cloning the repository

<script src="https://unpkg.com/shamsi-date-converter"></script>

<script>
  shamsi.gregorianToJalali(1989, 1, 24);
</script>
React
import * as shamsi from 'shamsi-date-converter';
...
render() {
  return (<p>{shamsi.gregorianToJalali(1989, 1, 24).join('/')}</p>);
}

Jquery

get library using bower, npm, cdn, or cloning the repository

<script src="https://unpkg.com/shamsi-date-converter"></script>

<script>
  $("#date").text(shamsi.gregorianToJalali(1989, 1, 24).join('/'));
</script>

Zero dependency

shamsi

If you don't need to pass date as input and you just want to pass year, month and date, you have to use shamsi

Format date

shamsi-formatter

If you want to pass formatted date as input or get formatted date from output like:

gregorianToJalali('1995/7/17'); // => 1374/4/26
// OR
jalaliToGregorian('1374/4/26'); // => 1995/7/17
// OR other formats as input or outputs

you have to use shamsi-formatter

Keywords

FAQs

Package last updated on 27 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc