GithubHelp home page GithubHelp logo

kottidev / hijri-date Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abdennour/hijri-date

0.0 2.0 0.0 1.21 MB

HijriDate

Home Page: https://abdennour.github.io/hijri-date

JavaScript 99.66% HTML 0.34%

hijri-date's Introduction

Build Status Coverage Status

Overview :

  • hijri-date provides HijriDate class which is the appropriate class to handle hijri dates like the built-in Date is the appropriate class to handle gregorian dates.

  • HijriDate class shared almost the same interface with Date class :

  • getFullYear
  • getDate (day of month)
  • getDay (day index of week)
  • getHours
  • ...
  • Works on client-side (browser) and server-side (NodeJS apps).

Install

npm install hijri-date --save;

or

<script src="https://rawgit.com/abdennour/hijri-date/master/cdn/hijri-date-latest.js" type="text/javascript" ></script>

Examples :

ES7 or after :

 import 'hijri-date';

 const today = new HijriDate();
 const day_eid_adha = new HijriDate(1438, 12, 10); // عيد الأضحى لسنة 1438
 const dayGreg = day_eid_adha.toGregorian()  ;
 //  Fri Sep 01 2017 00:00:00 GMT+0300 (AST)
//------ Convert from Gregorian to Hijri---------
 const nowGreg = new Date();
 const nowHijri = nowGreg.toHijri();     

If you want to work safety, use hijri-date/lib/safe as following :

import HijriDate,{toHijri} from 'hijri-date/lib/safe';

const today = new HijriDate();
const day_eid_adha = new HijriDate(1438, 12, 10); // عيد الأضحى لسنة 1438
const dayGreg = day_eid_adha.toGregorian()  ;
//  Fri Sep 01 2017 00:00:00 GMT+0300 (AST)
//------ Convert from Gregorian to Hijri---------
const nowGreg = new Date();
const nowHijri = toHijri(nowGreg);

ES6 or before :

 require('hijri-date')
 // then HijriDate class will be public as Date class .
// then, the same as above (see ES7 )
//....
  • safe import :
 const hijriSafe= require('hijri-date/lib/safe');
 const HijriDate =  hijriSafe.default;
 const toHijri   = hijriSafe.toHijri;
// then, the same as above (see ES7 safe)
const today = new HijriDate();
const day_eid_adha = new HijriDate(1438, 12, 10); // عيد الأضحى لسنة 1438
//......

Documentation:

Documentation was published here

Contribution :

  • Will be written soon . However, if you want to contribute, please, check 🔬 uni-tests firstly & how it was written.

History of releases :

  • 0.2.2 :

    • fix a bug related to english localisation .

    • overload constructor to accept default month (1) and default (date : 1)

    • add documentation

  • 0.2.0 :

    • The first bundled version is generated (then, it will be embedded in <script> directly without using npm)

    • New methods added to HijriDate class : isToday, isYesterday, isTomorrow, is, clone, ignoreTime,...etc

    • Chaining methods calls by returning the instance itself (this) if it is possible .

  • 0.1.5 :

    • Refactor code.
  • 0.1.4 :

    • supports locales (Hijri.locales).

    • locales can be extended .

    • apply format on HijriDate's instance new HijriDate().format('dddd')

    • Override toString to log the full date clearly such as Date class.

    • Substract days,hours, minutes,...

  • 0.1.3 : the first mature package.

License:

MIT .

hijri-date's People

Contributors

abdennour avatar kottidev avatar

Watchers

 avatar  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.