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

daxte

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

daxte

Date converter for different calendars

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Daxte

Using this class you will be able to convert dates between 3 different calendars

  • Gregorian
  • Jalali
  • Hijri

These are 3 available calendar contexts in this project. Now let's move into the code itself.

The base logic is to use date conversion methods to convert a given date to Julian Day Number, so it can be converted to the desired calendar later.

Constructors

Default Constructor

This is the default constructor that doesn't take any arguments and will get current date as its date. Note: The default calendar will be 'gregorian' in this constructor.

const daxte = new Daxte();

Date Object Constructor

This constructor will take a Date object as its only parameter and uses it for conversion. Note: The calendar will be 'gregorian' in this constructor.

const date = new Date(2020, 10, 7);

const daxte = new Daxte(date);

Date Constructor

In this constructor you can pass date in order of Year, Month, Day to use it for conversion. Note: You need to specify the calendar of the specified date, otherwise it uses 'gregorian' as default.

let daxte = new Daxte(1998, 1, 18);
let daxte = new Daxte(1376, 10, 28, 'jalali');

Methods

toJulian()

This method will return the julian day number of the instance

toGregorian()
toJalali()
toHijri()

These three methods are same as to method. They are named for an easier and meaningful usage.

{
    year: 2020,
    month: 10,
    day: 7,
    isLeapYear: true,
    lastDayInMonth: 31
}
to(calendar)

This method will return the date in the specified calendar

Keywords

FAQs

Package last updated on 07 Oct 2020

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