{"id":19553402,"url":"https://github.com/digicorp/date-management","last_synced_at":"2026-05-16T15:01:31.727Z","repository":{"id":76078183,"uuid":"68177076","full_name":"digicorp/date-management","owner":"digicorp","description":null,"archived":false,"fork":false,"pushed_at":"2016-09-14T06:56:56.000Z","size":12,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-08T20:43:20.343Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digicorp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-14T05:47:20.000Z","updated_at":"2016-11-04T19:17:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"7e2455a0-74cb-4da4-afee-6e48407b4be9","html_url":"https://github.com/digicorp/date-management","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digicorp%2Fdate-management","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digicorp%2Fdate-management/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digicorp%2Fdate-management/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digicorp%2Fdate-management/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digicorp","download_url":"https://codeload.github.com/digicorp/date-management/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240809833,"owners_count":19861164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T04:23:07.506Z","updated_at":"2026-05-16T15:01:26.671Z","avatar_url":"https://github.com/digicorp.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Date Library\n---\n#### Author : Ashish Vaghasiya\n##### Created on : 9th Nov 2015\n---\n## constant\n\n\n- OperationType\n\t* Day\\_of\\_Week\n\t* Day\\_Number\\_of\\_Week\n\t* Absolute\\_DateTime\n\t* First\\_Date\n\t* Last\\_Date\n\t* Date\\_of\\_Weekday\\_in\\_Week\n\t* Date\\_of\\_Weekday\\_in\\_Month\\_for\\_Given\\_Week\n\t* Date\\_of\\_Weekday\\_in\\_Quarter\\_for\\_Given\\_Month\\_and_Week\n\t* Date\\_of\\_Weekday\\_in\\_Year\\_for\\_Given\\_Week\n\t* Date\\_of\\_Weekday\\_in\\_Year\\_for\\_Given\\_Month\\_and\\_Week\n\t* Date\\_of\\_Weekday\\_in\\_Year\\_for\\_Given\\_Quarter\\_and\\_Month\\_and\\_Week\n\t* Week\\_of\\_Year\n\t* Calendar\\_Week\\_of\\_Month\n\t* Week\\_of\\_Month\\_by\\_Days\\_Distribution\\_for\\_as\\_Weeks\n\n\t---\n\n- DOW (Date Of Week)\n\t* Sunday\n\t* Monday\n\t* Tuesday\n\t* Wednesday\n\t* Thursday\n\t* Friday\n\t* Saturday\n\n\t---\n\n- GranularityType\n\t* Seconds\n\t* Minutes\n\t* Hours\n\t* Days\n\t* Weeks\n\t* Months\n\t* Quarters\n\t* HalfYears\n\t* Years\n\n\n## functions\n- DateLibrary.getDayOfWeek(Date, {JSON Object})\n\n\t* _example1_\n\t\t- _Description_ : find Week Name from `15th June 2015`.\n\t\t```javascript\n\t\t\tDateLibrary.getDayOfWeek(new Date(\"2015-06-15\"),\n\t\t\t\t{operationType:\"Day_of_Week\"}) // Output : Monday\n\t\t```\n\t\t- _Steps_\n\t\t\t- find day of week from given date[`Monday`]\t\t\t\n\n\t* _example2_\n\t\t- _Description_ :  if first day of week is `Sunday`, what day will be on `15th June 2015`.\n\t\t```javascript\n\t\t\tDateLibrary.getDayOfWeek(new Date(\"2015-06-15\"),\n\t\t\t\t{operationType:\"Day_Number_of_Week\",\n\t\t\t\t\tstartDayOfWeek:\"Sunday\"}) // Output : 1\n\t\t```\n\t\t- _Steps_\n\t\t\t- find Week of given date (Sunday as Start day of week) [`14th May 2015` to `20th May 2015`]\n\t\t\t- Given Date follow in 2nd day [`1`]\n---\n- DateLibrary.getRelativeDate(Date, {JSON Object})\n\n\t* _example1_\n\t\t- _Description_ :  Subtract 13 `Days` From Given Date\n\t\t```javascript\n\t\t\tDateLibrary.getRelativeDate(new Date(\"2015-06-15 14:10:39\"),\n\t\t\t\t{operationType: \"Absolute_DateTime\",\n\t\t\t\t\tgranularityType: \"Days\",value: -13}) // Output : Tue Jun 02 2015 14:10:39\n\t\t```\n\t\t- _Steps_\n\t\t\t- find Day from given date [`15`]\n\t\t\t- Subtract 13 Days from given date [`15-13`]\t\t\t\n\n\t* _example2_\n\t\t- _Description_ :  Subtract 13 `Hours` From Given Date\n\t\t```javascript\n\t\t\tDateLibrary.getRelativeDate(new Date(\"2015-06-15 14:10:39\"),\n\t\t\t\t{operationType: \"Absolute_DateTime\",\n\t\t\t\t\tgranularityType: \"Hours\",value: -13}) // Output : Tue Jun 15 2015 01:10:39\n\t\t```\n\t\t- _Steps_\n\t\t\t- find Hours from given date [`14`]\n\t\t\t- Subtract 13 Hours from given date [`14-13`]\t\t\t\n\n\t* _example3_\n\t\t- _Description_ :  get First Day of `quarter` From Given Date\n\t\t```javascript\n\t\t\tDateLibrary.getRelativeDate(new Date(\"2015-06-15\"),\n\t\t\t\t{operationType:\"First_Date\",granularityType:\"Quarters\"}) // Output : Wed Apr 01 2015 00:00:00\n\t\t```\n\t\t- _Steps_\n\t\t\t- find quarter for given date [`2nd Quarter`]\n\t\t\t- find first month of quarter [`Apr`]\t\t\t\t\t\t\n\n\t* _example4_\n\t\t- _Description_ :  get Last Day of `quarter` From Given Date\n\t\t```javascript\n\t\t\tDateLibrary.getRelativeDate(new Date(\"2015-06-15\"),\n\t\t\t\t{operationType:\"Last_Date\",granularityType:\"Quarters\"}) // Output : Wed Jun 30 2015 23:59:59\n\t\t```\n\t\t- _Steps_\n\t\t\t- find quarter for given date [`2nd Quarter`]\n\t\t\t- find last month of quarter [`Jun`]\n\n\t* _example5_\n\t\t- _Description_ :  if first day of week is `Sunday`, what date will be on `Wednesday`, if given date is `15th June 2015`.\n\t\t```javascript\n\t\t\tDateLibrary.getRelativeDate(iDate,\n\t\t\t\t{operationType: \"Date_of_Weekday_in_Week\",\n\t\t\t\t\tstartDayOfWeek:\"Sunday\",returnDayOfWeek:\"Wednesday\"}) // Output : Wed Jun 17 2015 00:00:00\n\t\t```\n\t\t- _Steps_\n\t\t\t- find Week of given date (Sunday as Start day of week) [`14th May 2015` to `21st May 2015`]\n\t\t\t- Wednesday will be on [`17th May 2015`]\n\n\t* _example6_\n\t\t- _Description_ :  if first day of week is `Wednesday`, what date will be on `1st day of week`, if given date is `15th June 2015`.\n\t\t```javascript\n\t\t\tDateLibrary.getRelativeDate(new Date(\"2015-06-15\"),\n\t\t\t\t{operationType:\"Date_of_Weekday_in_Week\",\n\t\t\t\t\tstartDayOfWeek:\"Wednesday\",returnDayNumberOfWeek:0}) // Output : Wed Jun 10 2015 00:00:00\t\t\t\n\t\t```\n\t\t- _Steps_\n\t\t\t- find Week of given date (Wednesday as Start day of week) [`10th May 2015` to `17th May 2015`]\n\t\t\t- 1st day of week should be [`10th May 2015`]\n\n\t* _example7_\n\t\t- _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.\n\t\t```javascript\n\t\t\tDateLibrary.getRelativeDate(new Date(\"2015-06-15\"),\n\t\t\t\t{operationType:\"Date_of_Weekday_in_Month_for_Given_Week\",\n\t\t\t\t\tstartDayOfWeek: \"Monday\",returnDayOfWeek:\"Friday\",WeekOfMonth:2}) // Output : Fri Jun 12 2015 00:00:00\n\t\t```\n\t\t- _Steps_\n\t\t\t- find month for given date [`Jun`]\n\t\t\t- find 2nd Week of month (Monday as Start day of week) [`8th May 2015` to `14th May 2015`]\n\t\t\t- Friday will be on [`12th May 2015`]\n\n\t* _example8_\n\t\t- _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.\n\t\t```javascript\n\t\t\tDateLibrary.getRelativeDate(new Date(\"2015-06-15\"),\n\t\t\t\t{operationType: \"Date_of_Weekday_in_Month_for_Given_Week\",\n\t\t\t\t\tstartDayOfWeek:\"Sunday\",returnDayNumberOfWeek:3,WeekOfMonth:3}) // Output : Wed Jun 17 2015 00:00:00\n\t\t```\n\t\t- _Steps_\n\t\t\t- find month for given date [`Jun`]\n\t\t\t- find 2nd Week of month (Sunday as Start day of week) [`14th May 2015` to `20th May 2015`]\n\t\t\t- The date of fourth day of week should be [`17th May 2015`]\n\n\t* _example9_\n\t\t- _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.\n\t\t```javascript\n\t\t\tDateLibrary.getRelativeDate(new Date(\"2015-06-15\"),\n\t\t\t\t{operationType:\"Date_of_Weekday_in_Quarter_for_Given_Month_and_Week\",\n\t\t\t\t\tstartDayOfWeek:\"Tuesday\",returnDayOfWeek:\"Friday\",MonthOfQuarter:2,WeekOfMonth:3}) // Output : 15th May 2015\n\t\t```\n\t\t- _Steps_\n\t\t\t- find quarter for given date [`2nd Quarter`]\n\t\t\t- find 2nd month of quarter [`May`]\n\t\t\t- find 3rd week of month (Tuesday as Start day of week) [`12th May 2015` to `18th May 2015`]\n\t\t\t- Friday will be on [`15th May 2015`]\n\n\t* _example10_\n\t\t- _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.\n\t\t```javascript\n\t\t\tDateLibrary.getRelativeDate(new Date(\"2015-06-15\"),\n\t\t\t\t{operationType: \"Date_of_Weekday_in_Year_for_Given_Week\" ,\n\t\t\t\t\tstartDayOfWeek: \"Tuesday\", returnDayOfWeek:\"Sunday\", WeekOfYear:18}) // Output : 3rd May 2015\n\t\t```\n\t\t- _Steps_\t\t\t\n\t\t\t- find 18 week follow in which month [`May`]\n\t\t\t- find 18th week of year (Tuesday as Start day of week) [`28th Apr 2015` to `4th May 2015`]\n\t\t\t- Sunday will be on [`3rd May 2015`]\n\n\t* _example11_\n\t\t- _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.\n\t\t```javascript\n\t\t\tDateLibrary.getRelativeDate(new Date(\"2015-06-15\"),\n\t\t\t\t{operationType:\"Date_of_Weekday_in_Year_for_Given_Month_and_Week\",\n\t\t\t\t\tstartDayOfWeek:\"Friday\", returnDayOfWeek:\"Tuesday\", WeekOfMonth:3, MonthOfYear:8}) // Output : 18th Aug 2015\n\t\t```\n\t\t- _Steps_\t\t\t\n\t\t\t- find 8th month in year [`Aug`]\n\t\t\t- find 3rd week of Month (Friday as Start day of week) [`14th Aug 2015` to `20th Aug 2015`]\n\t\t\t- Tuesday will be on [`18th Aug 2015`]\n\n\t* _example12_\n\t\t- _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.\n\t\t```javascript\n\t\t\tDateLibrary.getRelativeDate(new Date(\"2015-06-15\"),\n\t\t\t\t{operationType: \"Date_of_Weekday_in_Year_for_Given_Quarter_and_Month_and_Week\",\n\t\t\t\t\tstartDayOfWeek:\"Friday\",returnDayOfWeek:\"Tuesday\", QuarterOfYear:3, MonthOfQuarter:2, WeekOfMonth:3}) // Output : 18th Aug 2015\n\t\t```\n\t\t- _Steps_\t\t\t\n\t\t\t- find 3rd quarter of year [`Jul` to `Sep`]\n\t\t\t- find 2nd month of quarter [`Aug`]\n\t\t\t- find 3rd week of month (Friday as Start day of week) [`14th Aug 2015` to `20th Aug 2015`]\n\t\t\t- Tuesday will be on [`18th Aug 2015`]\n\n---\n\n- DateLibrary.getWeekNumber(Date, {JSON Object})\n\n\t* _example1_\n\t\t- _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.\n\t\t```javascript\n\t\t\tDateLibrary.getWeekNumber(new Date(\"2015-06-15\"),\n\t\t\t\t{operationType:\"Week_of_Year\",\n\t\t\t\t\tstartDayOfWeek:\"Tuesday\"}) // Output : 24\n\t\t```\n\t\t- _Steps_\n\t\t\t- find Previous month(s) week count (Tuesday as Start day of week)(`Jan+Feb+Mar+Apr+May`) [`5+4+5+4+4`]\n\t\t\t- find week count of given date month(`Jun`) [`2`]\n\t\t\t- total week count is [`5+4+5+4+4+2` = `24`]\n\n\t* _example2_\n\t\t- _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.\n\t\t```javascript\n\t\t\tDateLibrary.getWeekNumber(new Date(\"2015-06-15\"),\n\t\t\t\t{operationType:\"Calendar_Week_of_Month\",\n\t\t\t\t\tstartDayOfWeek: \"Tuesday\"}) // Output : 3\n\t\t```\n\t\t- _Steps_\t\t\t\n\t\t\t- find week count of given date month(Tuesday as Start day of week) [`3`]\n\t\t\t- total week count is [`3`]\n\n\t* _example3_\n\t\t- _Description_ :  what week number in month by days distribution will be follow in `15th June 2015` as one of the date.\n\t\t```javascript\n\t\t\tDateLibrary.getWeekNumber(new Date(\"2015-06-15\"),\n\t\t\t\t{operationType:\"Week_of_Month_by_Days_Distribution_for_as_Weeks\",\n\t\t\t\t\t\"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\n\t\t```\n\t\t- _Steps_\t\t\t\n\t\t\t- find total days in month [`30`]\n\t\t\t- find week count given date follow in which week [`6+6+6`=`18`]\n\t\t\t- total week count is [`3`]\n\n\n- DateLibrary.getDateDifference(fromDate,toDate,{JSON Object})\n\n\t* _example1_\n\t\t- _Description_ :  This takes three arguments from Date, to Date and JSON Object .It returns difference between them(base on granularityType days).\n\t\t```javascript\n\t\t\tDateLibrary.getDateDifference(new Date(\"2016-04-01\"),new Date(\"2016-04-16\"),\n\t\t\t\t{granularityType: \"days\"}) //output 15\n\t\t```\n\n\t* _example2_\n\t\t- _Description_ :  This takes three arguments from Date , to Date and JSON Object .It returns difference between them(base on granularityType seconds).\n\t\t```javascript\n\t\t\tDateLibrary.getDateDifference(new Date(\"2016-04-01 12:30:59\"),new Date(\"2016-04-16 15:45:59\"),\n\t\t\t\t{granularityType: \"seconds\"}) //output 1307700\n\t\t```\n\n\n- DateLibrary.getDifferenceInDays(fromDate,toDate,[array of excluded Date Object],[array of excluded days])\n\n\t* _example1_\n\t\t- _Description_ :  This takes two arguments from Date and to Date.It returns difference between them.\n\t\t```javascript\n\t\t\tDateLibrary.getDifferenceInDays(new Date(\"2016-04-01\"),new Date(\"2016-04-16\"))//output 15\n\t\t```\n\n\t* _example2_\n\t\t- _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.\n\t\t```javascript\n\t\t\tDateLibrary.getDifferenceInDays(new Date(\"2016-04-01\"),new Date(\"2016-04-16\"),\n\t\t\t\t[new Date(\"2016-04-05\"),new Date(\"2016-04-06\")],[])//output 13\n\t\t```\n\n\t* _example3_\n \t - _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.\n \t ```javascript\n \t\t DateLibrary.getDifferenceInDays(new Date(\"2016-04-01\"),new Date(\"2016-04-16\"),\n\t\t \t[new Date(\"2016-04-05\"),new Date(\"2016-04-06\")],[\"friday\"])//output 10\n \t ```\n\n- DateLibrary.getNumberToTimeStr(timeString, {JSON Object})\n\n\t* _example1_\n\t\t- _Description_ :  This takes two arguments timeString and JSON Object. It returns time.\n\t\t```javascript\n\t\t\tDateLibrary.getNumberToTimeStr(\"345\", {delimiter: \":\"}) //output 00:03:45\n\t\t```\n\n\t* _example2_\n\t\t- _Description_ :  This takes two arguments timeString and JSON Object. It returns time.\n\t\t```javascript\n\t\t\t\tDateLibrary.getNumberToTimeStr(\"5\", {delimiter: \"-\"}) //output 00-00-05\n\t```\n\t* _example3_\n\t\t- _Description_ :  This takes two arguments timeString and JSON Object. It returns time.\n\t\t```javascript\n\t\t\t\tDateLibrary.getNumberToTimeStr(\"145635\", {delimiter: \"~\"}) //output 14~56~35\n\t\t```\n\n- DateLibrary.julianToDate(julianString, timeString)\n\n \t* _example1_\n \t\t- _Description_ :  This takes two arguments julianString and timeString (optional). It returns date object.\n \t\t```javascript\n \t\t\t  DateLibrary.julianToDate(\"102536\") //output Fri Jun 20 2003 00:00:00\n \t\t```\n \t* _example2_\n\t \t- _Description_ :  This takes two arguments timeString and JSON Object. It returns time.\n\t \t```javascript\n\t \t\t\tDateLibrary.julianToDate(\"115536\",\"152645\") //output Sun Jun 19 2016 15:26:45\n\t \t```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigicorp%2Fdate-management","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigicorp%2Fdate-management","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigicorp%2Fdate-management/lists"}