npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jdate.js

v2.1.6

Published

Simple yet flexible Typescript | Javascript jalali date and time for developers ...

Downloads

17

Readme

Typescript | Javascript JDate Class ;)

Installation

npm i jdate.js

Usage

Typescript

import 'jdate.js';

let date = new Date();

console.log("Normal format: " + date.echo("Y/m/d"));
console.log("Jalali format: " + date.echoFa("Y/m/d"));

ECMAScript

require('jdate.js');

let date = new Date();

console.log("Normal format: " + date.echo("Y/m/d"));
console.log("Jalali format: " + date.echoFa("Y/m/d"));

Browser

<script src="https://cdn.jsdelivr.net/npm/jdate.js"></script>
<script type="text/javascript">
  (function() {
    var date = new Date();
    console.log("Normal format: " + date.echo("Y/m/d"));
    console.log("Jalali format: " + date.echoFa("Y/m/d"));
  })();
</script>

new Date()

Now with new Date() creates a new gregorian and jalali date object with the current date and time:

var date = new Date();
console.log( date.echoFa() );
console.log( date.echo() );
console.log( date );

~~>    شنبه، 25 دی 1400 - 19:22:22
~~>    Saturday January 15 2022 - 19:22:22
~~>    Sat Jan 15 2022 19:22:22 GMT+0330 (Iran Standard Time)

new Date(...).echo | echoFa

var date = new Date(2019, 4, 3, 10, 33, 30, 0);
console.log( date.echoFa("l، j F Y - H:i:s") );
console.log( date.echo("l، j F Y - H:i:s") );

~~>     جمعه، 13 اردیبهشت 1398 - 10:33:30
~~>     Friday، 3 May 2019 - 10:33:30

Format guide

Date.parseJalali(...)

You can parse specified shamsi or gregorian date from valid date string to convert it to milliseconds.

Date.parseJalali("1399");                    ~~> 1584662400000 ~~> 1399/01/01 - 03:30:00
Date.parseJalali("1399/02");                 ~~> 1587324600000 ~~> 1399/02/01 - 00:00:00
Date.parseJalali("1399/02/13");              ~~> 1588361400000 ~~> 1399/02/13 - 00:00:00
Date.parseJalali("1399/02/13 03:14:30");     ~~> 1588373070000 ~~> 1399/02/13 - 03:14:30
Date.parseJalali("2019/05/03 01:02:03");     ~~> 1556829123000 ~~> 1398/02/13 - 01:02:03
new Date(
    Date.parseJalali("1993/05/03 03:01:03")
).echoFa("Y/m/d - H:i:s")                   ~~> 1372/02/13 - 03:01:03

Get Jalali Date Methods

These methods can be used for getting information from a date object as a jalali date:

Set Jalali Date Methods

These methods can be used for set jalali date values (years, months, days, hours, minutes, seconds, milliseconds) for a date object:

License

JDate.js is available under the MIT license.