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

dinjs

v2.0.1

Published

dinjs is a JavaScript library for Nepali date arithmetic, specifically for the Bikram Sambat (BS) calendar system. It provides tools for converting dates, performing arithmetic, and calculating date differences.

Downloads

810

Readme

dinJS

dinjs is a JavaScript library for Nepali date arithmetic, specifically for the Bikram Sambat (BS) calendar system. It provides tools for converting dates, performing arithmetic, and calculating date differences.


Installation

Install dinjs using npm:

npm install dinjs

Range : 2000 BS - 2089 BS


Key Methods and Examples

1. Creating an Instance


import  { dinjs }  from "dinjs"
or
const  { dinjs }  = require("dinjs");


// Current date in BS
const currentDate = new dinjs();
console.log(currentDate.dateInBS);

// From AD date
const dateFromAD = new dinjs("2024-11-26", "YYYY-MM-DD");
console.log(dateFromAD.dateInBS);

// From BS date
const dateFromBS = new dinjs("2081-08-10", "YYYY-MM-DD", true);
console.log(dateFromBS.dateInBS);

1. Adding and Subtracting Dates

| Feature | Description | Example | |------------------|------------------------------------|-----------| | addDays | Adds a specified number of days | addDays(5) | | addMonths | Adds a specified number of Months | addMonths(6) | | addYears | Adds a specified number of Years | addYears(1) | | subtractDays | Subtracts a specified number of days | subtractDays(10) | | subtractMonths | Subtracts a specified number of months | subtractMonths(2) | | subtractYears | Subtracts a specified number of years | subtractYears(5) | | daysDifference | Calculates the difference in days between two dates | daysDifference(otherDate) |


// Adding years, months, and days
dateFromBS.addDate(1, 2, 15);
console.log(dateFromBS.dateInBS);

// Adding days
dateFromBS.addDays(10);
console.log(dateFromBS.dateInBS);

dateFromBS.addMonths(2);
console.log(dateFromBS.dateInBS);

dateFromBS.addYears(1);
console.log(dateFromBS.dateInBS);

// Subtracting days
dateFromBS.subtractDays(5);
console.log(dateFromBS.dateInBS);

dateFromBS.subtractMonths(3);
console.log(dateFromBS.dateInBS);

dateFromBS.subtractYears(1);
console.log(dateFromBS.dateInBS);


1. Calculating Date Differences


//Calculate days difference
const anotherDate = new dinjs("2081-08-20", "YYYY-MM-DD", true);
const diff = dateFromBS.daysDifference(anotherDate);
console.log(`Difference: ${diff} days`);

Format String Reference

| Cmponent | Description | Example | |------------------|------------------------------------|-----------| | YYYY | Year 4-units | 2060 | | MM | Month 2-units | 08 | | DD | Day 2-units | 10 |

demimeters - and / can be used. Any order of YYYY,MM,DD provided will save the date in that format and hence will always work with it in the same format