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

date-management

v1.0.1

Published

--- #### Author : Ashish Vaghasiya ##### Created on : 9th Nov 2015 --- ## constant

Downloads

235

Readme

Date Library


Author : Ashish Vaghasiya

Created on : 9th Nov 2015

constant

  • OperationType

    • Day_of_Week
    • Day_Number_of_Week
    • Absolute_DateTime
    • First_Date
    • Last_Date
    • Date_of_Weekday_in_Week
    • Date_of_Weekday_in_Month_for_Given_Week
    • Date_of_Weekday_in_Quarter_for_Given_Month_and_Week
    • Date_of_Weekday_in_Year_for_Given_Week
    • Date_of_Weekday_in_Year_for_Given_Month_and_Week
    • Date_of_Weekday_in_Year_for_Given_Quarter_and_Month_and_Week
    • Week_of_Year
    • Calendar_Week_of_Month
    • Week_of_Month_by_Days_Distribution_for_as_Weeks

  • DOW (Date Of Week)

    • Sunday
    • Monday
    • Tuesday
    • Wednesday
    • Thursday
    • Friday
    • Saturday

  • GranularityType

    • Seconds
    • Minutes
    • Hours
    • Days
    • Weeks
    • Months
    • Quarters
    • HalfYears
    • Years

functions

  • DateLibrary.getDayOfWeek(Date, {JSON Object})

    • example1

      • Description : find Week Name from 15th June 2015.
      	DateLibrary.getDayOfWeek(new Date("2015-06-15"),
      		{operationType:"Day_of_Week"}) // Output : Monday
      • Steps
        • find day of week from given date[Monday]
    • example2

      • Description : if first day of week is Sunday, what day will be on 15th June 2015.
      	DateLibrary.getDayOfWeek(new Date("2015-06-15"),
      		{operationType:"Day_Number_of_Week",
      			startDayOfWeek:"Sunday"}) // Output : 1
      • Steps
        • find Week of given date (Sunday as Start day of week) [14th May 2015 to 20th May 2015]
        • Given Date follow in 2nd day [1]

  • DateLibrary.getRelativeDate(Date, {JSON Object})

    • example1

      • Description : Subtract 13 Days From Given Date
      	DateLibrary.getRelativeDate(new Date("2015-06-15 14:10:39"),
      		{operationType: "Absolute_DateTime",
      			granularityType: "Days",value: -13}) // Output : Tue Jun 02 2015 14:10:39
      • Steps
        • find Day from given date [15]
        • Subtract 13 Days from given date [15-13]
    • example2

      • Description : Subtract 13 Hours From Given Date
      	DateLibrary.getRelativeDate(new Date("2015-06-15 14:10:39"),
      		{operationType: "Absolute_DateTime",
      			granularityType: "Hours",value: -13}) // Output : Tue Jun 15 2015 01:10:39
      • Steps
        • find Hours from given date [14]
        • Subtract 13 Hours from given date [14-13]
    • example3

      • Description : get First Day of quarter From Given Date
      	DateLibrary.getRelativeDate(new Date("2015-06-15"),
      		{operationType:"First_Date",granularityType:"Quarters"}) // Output : Wed Apr 01 2015 00:00:00
      • Steps
        • find quarter for given date [2nd Quarter]
        • find first month of quarter [Apr]
    • example4

      • Description : get Last Day of quarter From Given Date
      	DateLibrary.getRelativeDate(new Date("2015-06-15"),
      		{operationType:"Last_Date",granularityType:"Quarters"}) // Output : Wed Jun 30 2015 23:59:59
      • Steps
        • find quarter for given date [2nd Quarter]
        • find last month of quarter [Jun]
    • example5

      • Description : if first day of week is Sunday, what date will be on Wednesday, if given date is 15th June 2015.
      	DateLibrary.getRelativeDate(iDate,
      		{operationType: "Date_of_Weekday_in_Week",
      			startDayOfWeek:"Sunday",returnDayOfWeek:"Wednesday"}) // Output : Wed Jun 17 2015 00:00:00
      • Steps
        • find Week of given date (Sunday as Start day of week) [14th May 2015 to 21st May 2015]
        • Wednesday will be on [17th May 2015]
    • example6

      • Description : if first day of week is Wednesday, what date will be on 1st day of week, if given date is 15th June 2015.
      	DateLibrary.getRelativeDate(new Date("2015-06-15"),
      		{operationType:"Date_of_Weekday_in_Week",
      			startDayOfWeek:"Wednesday",returnDayNumberOfWeek:0}) // Output : Wed Jun 10 2015 00:00:00			
      • Steps
        • find Week of given date (Wednesday as Start day of week) [10th May 2015 to 17th May 2015]
        • 1st day of week should be [10th May 2015]
    • example7

      • Description : if first day of week is Monday, what date will be on Friday of 2nd Week of Month containing 15th June 2015 as one of the date.
      	DateLibrary.getRelativeDate(new Date("2015-06-15"),
      		{operationType:"Date_of_Weekday_in_Month_for_Given_Week",
      			startDayOfWeek: "Monday",returnDayOfWeek:"Friday",WeekOfMonth:2}) // Output : Fri Jun 12 2015 00:00:00
      • Steps
        • find month for given date [Jun]
        • find 2nd Week of month (Monday as Start day of week) [8th May 2015 to 14th May 2015]
        • Friday will be on [12th May 2015]
    • example8

      • Description : if first day of week is Sunday, what date will be fourth day of 3rd Week of Month containing 15th June 2015 as one of the date.
      	DateLibrary.getRelativeDate(new Date("2015-06-15"),
      		{operationType: "Date_of_Weekday_in_Month_for_Given_Week",
      			startDayOfWeek:"Sunday",returnDayNumberOfWeek:3,WeekOfMonth:3}) // Output : Wed Jun 17 2015 00:00:00
      • Steps
        • find month for given date [Jun]
        • find 2nd Week of month (Sunday as Start day of week) [14th May 2015 to 20th May 2015]
        • The date of fourth day of week should be [17th May 2015]
    • example9

      • Description : if first day of week is Tuesday, what date will be on Friday of 3rd week of 2nd month of quarter containing 15th June 2015 as one of the date.
      	DateLibrary.getRelativeDate(new Date("2015-06-15"),
      		{operationType:"Date_of_Weekday_in_Quarter_for_Given_Month_and_Week",
      			startDayOfWeek:"Tuesday",returnDayOfWeek:"Friday",MonthOfQuarter:2,WeekOfMonth:3}) // Output : 15th May 2015
      • Steps
        • find quarter for given date [2nd Quarter]
        • find 2nd month of quarter [May]
        • find 3rd week of month (Tuesday as Start day of week) [12th May 2015 to 18th May 2015]
        • Friday will be on [15th May 2015]
    • example10

      • Description : if first day of week is Tuesday, what date will be on Sunday of 18th Week of year containing 15th June 2015 as one of the date.
      	DateLibrary.getRelativeDate(new Date("2015-06-15"),
      		{operationType: "Date_of_Weekday_in_Year_for_Given_Week" ,
      			startDayOfWeek: "Tuesday", returnDayOfWeek:"Sunday", WeekOfYear:18}) // Output : 3rd May 2015
      • Steps
        • find 18 week follow in which month [May]
        • find 18th week of year (Tuesday as Start day of week) [28th Apr 2015 to 4th May 2015]
        • Sunday will be on [3rd May 2015]
    • example11

      • Description : if first day of week is Friday, what date will be on Tuesday of 3rd Week of 8th month of year containing 15th June 2015 as one of the date.
      	DateLibrary.getRelativeDate(new Date("2015-06-15"),
      		{operationType:"Date_of_Weekday_in_Year_for_Given_Month_and_Week",
      			startDayOfWeek:"Friday", returnDayOfWeek:"Tuesday", WeekOfMonth:3, MonthOfYear:8}) // Output : 18th Aug 2015
      • Steps
        • find 8th month in year [Aug]
        • find 3rd week of Month (Friday as Start day of week) [14th Aug 2015 to 20th Aug 2015]
        • Tuesday will be on [18th Aug 2015]
    • example12

      • Description : if first day of week is Friday, what date will be on Tuesday of 3rd Week of 2nd month of 3rd quarter of year containing 15th June 2015 as one of the date.
      	DateLibrary.getRelativeDate(new Date("2015-06-15"),
      		{operationType: "Date_of_Weekday_in_Year_for_Given_Quarter_and_Month_and_Week",
      			startDayOfWeek:"Friday",returnDayOfWeek:"Tuesday", QuarterOfYear:3, MonthOfQuarter:2, WeekOfMonth:3}) // Output : 18th Aug 2015
      • Steps
        • find 3rd quarter of year [Jul to Sep]
        • find 2nd month of quarter [Aug]
        • find 3rd week of month (Friday as Start day of week) [14th Aug 2015 to 20th Aug 2015]
        • Tuesday will be on [18th Aug 2015]

  • DateLibrary.getWeekNumber(Date, {JSON Object})

    • example1

      • Description : if first day of week is Tuesday, what week number in year will be follow in 15th June 2015 as one of the date.
      	DateLibrary.getWeekNumber(new Date("2015-06-15"),
      		{operationType:"Week_of_Year",
      			startDayOfWeek:"Tuesday"}) // Output : 24
      • Steps
        • find Previous month(s) week count (Tuesday as Start day of week)(Jan+Feb+Mar+Apr+May) [5+4+5+4+4]
        • find week count of given date month(Jun) [2]
        • total week count is [5+4+5+4+4+2 = 24]
    • example2

      • Description : if first day of week is Tuesday, what week number in month will be follow in 15th June 2015 as one of the date.
      	DateLibrary.getWeekNumber(new Date("2015-06-15"),
      		{operationType:"Calendar_Week_of_Month",
      			startDayOfWeek: "Tuesday"}) // Output : 3
      • Steps
        • find week count of given date month(Tuesday as Start day of week) [3]
        • total week count is [3]
    • example3

      • Description : what week number in month by days distribution will be follow in 15th June 2015 as one of the date.
      	DateLibrary.getWeekNumber(new Date("2015-06-15"),
      		{operationType:"Week_of_Month_by_Days_Distribution_for_as_Weeks",
      			"28days":[5,6,5,6,6],"29days":[5,6,6,6,6],"30days":[6,6,6,6,6],"31days":[5,5,5,5,5,6]}) // Output : 3
      • Steps
        • find total days in month [30]
        • find week count given date follow in which week [6+6+6=18]
        • total week count is [3]
  • DateLibrary.getDateDifference(fromDate,toDate,{JSON Object})

    • example1

      • Description : This takes three arguments from Date, to Date and JSON Object .It returns difference between them(base on granularityType days).
      	DateLibrary.getDateDifference(new Date("2016-04-01"),new Date("2016-04-16"),
      		{granularityType: "days"}) //output 15
    • example2

      • Description : This takes three arguments from Date , to Date and JSON Object .It returns difference between them(base on granularityType seconds).
      	DateLibrary.getDateDifference(new Date("2016-04-01 12:30:59"),new Date("2016-04-16 15:45:59"),
      		{granularityType: "seconds"}) //output 1307700
  • DateLibrary.getDifferenceInDays(fromDate,toDate,[array of excluded Date Object],[array of excluded days])

    • example1

      • Description : This takes two arguments from Date and to Date.It returns difference between them.
      	DateLibrary.getDifferenceInDays(new Date("2016-04-01"),new Date("2016-04-16"))//output 15
    • example2

      • Description : This takes four arguments from Date, to Date and array of dates to be excluded and empty array exclude days.It returns difference between them.
      	DateLibrary.getDifferenceInDays(new Date("2016-04-01"),new Date("2016-04-16"),
      		[new Date("2016-04-05"),new Date("2016-04-06")],[])//output 13
    • example3

    • Description : This takes four arguments from Date, to Date and array of dates to be excluded and array of days to be excluded.It returns difference between them.
        DateLibrary.getDifferenceInDays(new Date("2016-04-01"),new Date("2016-04-16"),
        	[new Date("2016-04-05"),new Date("2016-04-06")],["friday"])//output 10
  • DateLibrary.getNumberToTimeStr(timeString, {JSON Object})

    • example1

      • Description : This takes two arguments timeString and JSON Object. It returns time.
      	DateLibrary.getNumberToTimeStr("345", {delimiter: ":"}) //output 00:03:45
    • example2

      • Description : This takes two arguments timeString and JSON Object. It returns time.
      		DateLibrary.getNumberToTimeStr("5", {delimiter: "-"}) //output 00-00-05
    * _example3_
    	- _Description_ :  This takes two arguments timeString and JSON Object. It returns time.
    	```javascript
    			DateLibrary.getNumberToTimeStr("145635", {delimiter: "~"}) //output 14~56~35
    	```
    
  • DateLibrary.julianToDate(julianString, timeString)

    • example1
      • Description : This takes two arguments julianString and timeString (optional). It returns date object.
      	  DateLibrary.julianToDate("102536") //output Fri Jun 20 2003 00:00:00
    • example2
      • Description : This takes two arguments timeString and JSON Object. It returns time.
      		DateLibrary.julianToDate("115536","152645") //output Sun Jun 19 2016 15:26:45