{"id":24501042,"url":"https://github.com/thomasdev-de/js-date-extensions","last_synced_at":"2025-03-15T07:24:16.571Z","repository":{"id":62803992,"uuid":"560608899","full_name":"ThomasDev-de/Js-Date-Extensions","owner":"ThomasDev-de","description":"A few useful extensions for the javascript object Date.","archived":false,"fork":false,"pushed_at":"2023-02-10T07:49:30.000Z","size":32,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-07-29T09:09:42.255Z","etag":null,"topics":["adddays","addmonth","calendar","clone","copy","date","fromnow","getdaynames","getdaysinmonth","getfirstdayofmonth","getfirstdayofweek","getlastdayofmonth","getlastdayofweek","getmonthnames","getweek","isleapyear","javascript","subdays","submonth"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThomasDev-de.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-11-01T21:42:53.000Z","updated_at":"2022-11-10T08:02:46.000Z","dependencies_parsed_at":"2024-11-21T06:46:12.545Z","dependency_job_id":null,"html_url":"https://github.com/ThomasDev-de/Js-Date-Extensions","commit_stats":{"total_commits":25,"total_committers":3,"mean_commits":8.333333333333334,"dds":0.4,"last_synced_commit":"169d9716523580166d46e23de40753114267a571"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasDev-de%2FJs-Date-Extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasDev-de%2FJs-Date-Extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasDev-de%2FJs-Date-Extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasDev-de%2FJs-Date-Extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThomasDev-de","download_url":"https://codeload.github.com/ThomasDev-de/Js-Date-Extensions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243697701,"owners_count":20332998,"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":["adddays","addmonth","calendar","clone","copy","date","fromnow","getdaynames","getdaysinmonth","getfirstdayofmonth","getfirstdayofweek","getlastdayofmonth","getlastdayofweek","getmonthnames","getweek","isleapyear","javascript","subdays","submonth"],"created_at":"2025-01-21T22:22:58.608Z","updated_at":"2025-03-15T07:24:16.550Z","avatar_url":"https://github.com/ThomasDev-de.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Js-Date-Extensions\nA few useful extensions for the javascript object Date\n## Table of contents\n- [Js-Date-Extensions](#js-date-extensions)\n    * [Table of contents](#table-of-contents)\n    * [generell methods](#generell-methods)\n        + [setLocale](#setlocale)\n        + [getUnits](#getunits)\n        + [getDayNames](#getdaynames)\n        + [getMonthNames](#getmonthnames)\n    * [Method that manipulate the Date object](#method-that-manipulate-the-date-object)\n        + [addDays](#adddays)\n        + [subDays](#subdays)\n        + [addMonths](#addmonths)\n        + [subMonths](#submonths)\n    * [Methods that return a new instance of the Date object](#methods-that-return-a-new-instance-of-the-date-object)\n        + [clone](#clone)\n        + [copy](#copy)\n        + [getFirstDayOfMonth](#getfirstdayofmonth)\n        + [getLastDayOfMonth](#getlastdayofmonth)\n        + [getFirstDayOfWeek](#getfirstdayofweek)\n        + [getLastDayOfWeek](#getlastdayofweek)\n    * [Test methods that return none date object](#test-methods-that-return-none-date-object)\n        + [isLeapYear](#isleapyear)\n        + [isMonday, isTuesday, isWednesday, isThursday, isFriday, isSaturday, isSunday](#ismonday--istuesday--iswednesday--isthursday--isfriday--issaturday--issunday)\n        + [getDaysInMonth](#getdaysinmonth)\n        + [getWeek](#getweek)\n        + [getCountWeeks](#getcountweeks)\n        + [getCountDays](#getcountdays)\n        + [fromNow](#fromnow)\n        + [getDayName](#getdayname)\n        + [getMonthName](#getmonthname)\n        + [getMonthCalendar](#getmonthcalendar)\n## generell methods\n\n### setLocale\nSet the language\n```js\n// example\nDate.setLocale('de');\n```\n### getUnits\nFetches the time units in milliseconds  \n@return {object}\n```js\n// example\nDate.getUnits();\n// { year: 31536000000, month: 2628000000, week: 604800000, day: 86400000, hour: 3600000, minute: 60000, second: 1000 }\n```\n\n### getDayNames\n@param {boolean} abbreviation Default `false`  \n@returns {string[]}\n```js\n// example\nDate.getDayNames(true); // [ \"Mo\", \"Di\", \"Mi\", \"Do\", \"Fr\", \"Sa\", \"So\" ]\n```\n### getMonthNames\n@param {boolean} abbreviation Default `false`  \n@returns {string[]}\n```js\n// example\nDate.getMonthNames(true); // [ \"Jan\", \"Feb\", \"Mär\", \"Apr\", \"Mai\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Okt\", \"Nov\", \"Dez\"]\n```\n## Method that manipulate the Date object\n### addDays\nAdds a specified number of days to the date  \n@param {number} days  \n@return {Date}\n```js\n// example\nlet date = new Date('2022-11-01');\ndate.addDays(4); // 2022-11-05\n```\n### subDays\nSubtracts a specified number of days from the date  \n@param {number} days  \n@returns {Date}\n```js\n// example\nlet date = new Date('2022-11-01');\ndate.subDays(4); // 2022-10-28\n```\n### addMonths\nAdds a specified number of months to the date  \n@param {number} months  \n@returns {Date}\n```js\n// example\nlet date = new Date('2022-11-01');\ndate.addMonths(4); // 2023-03-01\n```\n\n### subMonths\nSubtracts a specified number of months from the date  \n@param {number} months  \n@returns {Date}\n```js\n// example\nlet date = new Date('2022-11-01');\ndate.subMonths(1); // 2022-10-01\n```\n## Methods that return a new instance of the Date object\n\n### clone\n@returns {Date}\n```js\n// example\nlet date = new Date('2022-11-01');\nlet cloneDate = date.clone(); // 2022-11-01\n```\n### copy\nReturns a new instance of the Date object (alias of `clone`)  \n@returns {Date}\n```js\n// example\nlet date = new Date('2022-11-01');\nlet copyDate = date.copy(); // 2022-11-01\n```\n### getFirstDayOfMonth\nDetermine the first day of the current month  \n@returns {Date}\n```js\n// example\nlet date = new Date('2022-11-10');\nlet firstOfMonth = date.getFirstDayOfMonth(); // 2022-11-01\n```\n### getLastDayOfMonth\nDetermine the last day of the current month  \n@returns {Date}\n```js\n// example\nlet date = new Date('2022-11-10');\nlet firstOfMonth = date.getLastDayOfMonth(); // 2022-11-30\n```\n### getFirstDayOfWeek\n\nDetermine the previous Monday of the current date  \n@returns {Date}\n\n```js\n// example\nlet date = new Date('2022-11-10');\nlet prevMonday = date.getFirstDayOfWeek(); // 2022-11-07\n```\n### getLastDayOfWeek\nDetermine the Sunday of the current date  \n@returns {Date}\n```js\n// example\nlet date = new Date('2022-11-10');\nlet nextSunday = date.getLastDayOfWeek(); // 2022-11-13\n```\n\n## Test methods that return none date object\n### isLeapYear\nChecks if the year of the date is a leap year  \n@returns {boolean}\n```js\n// example\nlet date = new Date('2024-11-01');\nif (date.isLeapYear()) // true\n{\n    // do something\n}\n```\n### isMonday, isTuesday, isWednesday, isThursday, isFriday, isSaturday, isSunday, isWeekend\nChecks the date for a weekday  \n@returns {boolean}\n```js\n// example\nlet date = new Date('2022-11-01');\ndate.isMonday(); // false\ndate.isTuesday(); // true\ndate.isWednesday(); // false\ndate.isThursday(); // false\ndate.isFriday(); // false\ndate.isSaturday(); // false\ndate.isSunday(); // false\ndate.isWeekend(); // false\n```\n### getDaysInMonth\nDetermine the number of days in the current month  \n@returns {number}\n```js\n// example\nlet date = new Date('2022-11-01');\ndate.getDaysInMonth(); // 30\n```\n\n### getWeek\nDetermines the calendar week of the date  \n@returns {number}\n```js\n// example\nlet date = new Date('2022-11-01');\ndate.getWeek(); // 44 \n```\n### getCountWeeks\nDetermines the number of weeks between two dates  \n@param {Date} toDate  \n@returns {number}\n```js\n// example\nlet date = new Date('2022-11-01');\nlet toDate = new Date('2022-11-14');\ndate.getCountWeeks(toDate); // 2\n```\n### getCountDays\nDetermines the number of days between two dates  \n@param {Date} toDate  \n@returns {number}\n```js\n// example\nlet date = new Date('2022-11-01');\nlet toDate = new Date('2022-11-14');\ndate.getCountDays(toDate); // 14\n```\n### fromNow\n```js\nlet date = new Date('2022-11-06 23:54:00');\n// Now: 2022-11-07 05:55:00\ndate.fromNow(); // vor 6 Stunden\n```\n### getDayName\n```js\nlet date = new Date('2022-11-06 23:54:00');\n// Now: 2022-11-07 05:55:00\ndate.getDayName(); // Sonntag\n```\n### getMonthName\n```js\nlet date = new Date('2022-11-06 23:54:00');\n// Now: 2022-11-07 05:55:00\ndate.getMonthName(); // November\n```\n### getMonthCalendar\nReturns all data of one month as array  \n@return {*[]}\n\n```js\n// example\nlet date = new Date('2022-11-01');\nlet result = date.getMonthCalendar();\n// output result\n[\n    {\n        \"week\": 44,\n        \"days\": [\n            \"2022-10-31T23:00:00.000Z\",\n            \"2022-11-01T23:00:00.000Z\",\n            \"2022-11-02T23:00:00.000Z\",\n            \"2022-11-03T23:00:00.000Z\",\n            \"2022-11-04T23:00:00.000Z\",\n            \"2022-11-05T23:00:00.000Z\",\n            \"2022-11-06T23:00:00.000Z\"\n        ]\n    },\n    {\n        \"week\": 45,\n        \"days\": [\n            \"2022-11-07T23:00:00.000Z\",\n            \"2022-11-08T23:00:00.000Z\",\n            \"2022-11-09T23:00:00.000Z\",\n            \"2022-11-10T23:00:00.000Z\",\n            \"2022-11-11T23:00:00.000Z\",\n            \"2022-11-12T23:00:00.000Z\",\n            \"2022-11-13T23:00:00.000Z\"\n        ]\n    },\n    {\n        \"week\": 46,\n        \"days\": [\n            \"2022-11-14T23:00:00.000Z\",\n            \"2022-11-15T23:00:00.000Z\",\n            \"2022-11-16T23:00:00.000Z\",\n            \"2022-11-17T23:00:00.000Z\",\n            \"2022-11-18T23:00:00.000Z\",\n            \"2022-11-19T23:00:00.000Z\",\n            \"2022-11-20T23:00:00.000Z\"\n        ]\n    },\n    {\n        \"week\": 47,\n        \"days\": [\n            \"2022-11-21T23:00:00.000Z\",\n            \"2022-11-22T23:00:00.000Z\",\n            \"2022-11-23T23:00:00.000Z\",\n            \"2022-11-24T23:00:00.000Z\",\n            \"2022-11-25T23:00:00.000Z\",\n            \"2022-11-26T23:00:00.000Z\",\n            \"2022-11-27T23:00:00.000Z\"\n        ]\n    },\n    {\n        \"week\": 48,\n        \"days\": [\n            \"2022-11-28T23:00:00.000Z\",\n            \"2022-11-29T23:00:00.000Z\",\n            \"2022-11-30T23:00:00.000Z\",\n            \"2022-12-01T23:00:00.000Z\",\n            \"2022-12-02T23:00:00.000Z\",\n            \"2022-12-03T23:00:00.000Z\",\n            \"2022-12-04T23:00:00.000Z\"\n        ]\n    }\n]\n```\n### getWeekCalendar\nReturns all data of one week as array  \n@return {*[]}\n\n```js\n// example\nlet date = new Date('2023-02-09');\nlet result = date.getWeekCalendar();\n// output result\n[\n    \"2023-02-06T23:00:00.000Z\",\n    \"2023-02-07T23:00:00.000Z\",\n    \"2023-02-08T23:00:00.000Z\",\n    \"2023-02-09T23:00:00.000Z\",\n    \"2023-02-10T23:00:00.000Z\",\n    \"2023-02-11T23:00:00.000Z\",\n    \"2023-02-12T23:00:00.000Z\",\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasdev-de%2Fjs-date-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomasdev-de%2Fjs-date-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasdev-de%2Fjs-date-extensions/lists"}