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

@zero65tech/date-string-ist

v4.0.2

Published

Date String Manipulation (IST)

Downloads

172

Readme

date-string-ist Utility

Introduction

This JavaScript library is designed to simplify date-related operations, specifically tailored for the Indian financial system. The library is crafted to assist in various date manipulations crucial for financial calculations, ensuring that all time values are in Indian Standard Time (IST) and date formats follow the "YYYY-MM-DD" pattern.

Installation

npm i @zero65tech/date-string-ist

Functions

1. from(date)

This function takes a Date object or a timestamp and returns the date in the format "YYYY-MM-DD". It adjusts the input date by adding 5.5 hours to it.

Example:

const formattedDate = from(new Date()); // Returns a string representing today's date

2. tomorrow()

Returns the date string for the next day in the format "YYYY-MM-DD".

Example:

const nextDay = tomorrow(); // Returns a string representing tomorrow's date

3. today()

Returns the date string for the current day in the format "YYYY-MM-DD".

Example:

const currentDate = today(); // Returns a string representing today's date

4. yesterday()

Returns the date string for the previous day in the format "YYYY-MM-DD".

Example:

const previousDay = yesterday(); // Returns a string representing yesterday's date

5. lastWeek()

Returns the date string for seven days ago in the format "YYYY-MM-DD".

Example:

const lastWeekDate = lastWeek(); // Returns a string representing the date seven days ago

6. shift(dateStr, days)

Shifts a given date string by a specified number of days. If no days are provided, the original date string is returned.

Example:

const shiftedDate = shift('2024-01-30', 2); // Shifts the date two days ahead
// Output - '2024-02-01'

7. getDuration(startDate, endDate)

Calculates the duration in days between two dates. If no start date is provided, it defaults to the current date.

Example:

const duration = getDuration('2024-01-30', '2024-02-01'); // Returns the duration between the two dates
// Output - 2

8. getWeekStart(dateStr)

Returns the date string for the start of the week (Monday) for a given date.

Example:

const weekStartDate = getWeekStart('2023-01-06'); // Returns the date of the Monday of the week
// Output - '2024-01-01'

9. getWeekEnd(dateStr)

Returns the date string for the end of the week (Sunday) for a given date.

Example:

const weekEndDate = getWeekEnd('2023-01-06'); // Returns the date of the Sunday of the week
// Output - '2024-01-07'

10. getFyStart(dateStr)

Returns the start date string of the fiscal year for a given date. If no date is provided, it defaults to the current date.

Example:

const fyStartDate = getFyStart('2023-06-01'); // Returns the start date of the fiscal year
// Output - '2023-04-01'

11. getFyEnd(dateStr)

Returns the end date string of the fiscal year for a given date. If no date is provided, it defaults to the current date.

Example:

const fyEndDate = getFyEnd('2023-06-01'); // Returns the end date of the fiscal year
// Output - '2024-03-31'

12. getQtr(dateStr)

Returns the fiscal quarter for a given date in the format "q1", "q2", "q3", or "q4".

Example:

const quarter = getQtr('2023-06-01'); // Returns the fiscal quarter for the date
// Output - 'q1'

13. getTaxQtr(dateStr)

Returns the tax quarter for a given date in the format "q1", "q2", "q3", "q4", or "q5".

Example:

const taxQuarter = getTaxQtr('2023-06-01'); // Returns the tax quarter for the date
// Output - 'q1'

14. getFy(dateStr)

Returns the fiscal year for a given date in the format "fyYYYY".

Example:

const fiscalYear = getFy('2023-06-01'); // Returns the fiscal year for the date
// Output - 'fy23'

15. getFyDuration(dateStr)

Calculates the duration in days of the fiscal year for a given date. If no date is provided, it defaults to the current date.

Example:

const fyDuration = getFyDuration('2023-06-01'); // Returns the duration of the fiscal year
// Output - 366