{"_id":"date-extended","_rev":"3220791","name":"date-extended","description":"Additional date extensions with a chainable api","dist-tags":{"latest":"0.0.6"},"maintainers":[{"name":"damartin","email":"doug@dougamartin.com"}],"time":{"modified":"2024-03-21T07:22:07.000Z","created":"2013-01-16T21:25:04.796Z","0.0.6":"2014-04-01T17:59:13.115Z","0.0.5":"2013-06-05T05:31:13.259Z","0.0.4":"2013-04-16T15:45:47.219Z","0.0.3":"2013-01-22T07:08:28.299Z","0.0.2":"2013-01-19T05:07:11.324Z","0.0.1":"2013-01-16T21:25:04.796Z"},"users":{},"author":{"name":"Doug Martin"},"repository":{"type":"git","url":"git:git@github.com:doug-martin/date-extended.git"},"versions":{"0.0.6":{"name":"date-extended","version":"0.0.6","description":"Additional date extensions with a chainable api","main":"index.js","scripts":{"test":"it -r dot"},"repository":{"type":"git","url":"git:git@github.com:doug-martin/date-extended.git"},"keywords":["Date","extender","utilities"],"testling":{"files":"test/browserling.js","browsers":["ie/8..latest","chrome/20..latest","firefox/14..latest","safari/latest","iphone/6","ipad/6"]},"author":{"name":"Doug Martin"},"license":"MIT","dependencies":{"extended":"~0.0.3","is-extended":"~0.0.3","array-extended":"~0.0.3"},"devDependencies":{"it":"~0.2.0","grunt-it":"~0.3.0","grunt-contrib-uglify":"~0.2.0","grunt":"~0.4.1","grunt-contrib-jshint":"~0.4.3"},"bugs":{"url":"https://github.com/doug-martin/date-extended/issues"},"homepage":"https://github.com/doug-martin/date-extended","_id":"date-extended@0.0.6","dist":{"shasum":"23802d57dd1bf7818813fe0c32e851a86da267c9","size":22254,"noattachment":false,"key":"/date-extended/-/date-extended-0.0.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/date-extended/download/date-extended-0.0.6.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"damartin","email":"doug@dougamartin.com"},"maintainers":[{"name":"damartin","email":"doug@dougamartin.com"}],"directories":{},"publish_time":1396375153115,"_hasShrinkwrap":false,"_cnpm_publish_time":1396375153115,"_cnpmcore_publish_time":"2021-12-16T13:32:50.150Z"},"0.0.5":{"name":"date-extended","version":"0.0.5","description":"Additional date extensions with a chainable api","main":"index.js","scripts":{"test":"it -r dot"},"repository":{"type":"git","url":"git:git@github.com:doug-martin/date-extended.git"},"keywords":["Date","extender","utilities"],"testling":{"files":"test/browserling.js","browsers":["ie/6..latest","chrome/20..latest","firefox/14..latest","safari/latest","iphone/6","ipad/6"]},"author":{"name":"Doug Martin"},"license":"MIT","dependencies":{"extended":"~0.0.3","is-extended":"~0.0.3","array-extended":"~0.0.3","grunt-contrib-uglify":"~0.2.0","grunt":"~0.4.1","grunt-contrib-jshint":"~0.4.3"},"devDependencies":{"it":"~0.2.0","grunt-it":"~0.3.0"},"readmeFilename":"README.md","bugs":{"url":"https://github.com/doug-martin/date-extended/issues"},"_id":"date-extended@0.0.5","dist":{"shasum":"81d4b656fae2ecf797400cfe3889eb9067e28846","size":22256,"noattachment":false,"key":"/date-extended/-/date-extended-0.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/date-extended/download/date-extended-0.0.5.tgz"},"_from":".","_npmVersion":"1.2.23","_npmUser":{"name":"damartin","email":"doug@dougamartin.com"},"maintainers":[{"name":"damartin","email":"doug@dougamartin.com"}],"directories":{},"publish_time":1370410273259,"_hasShrinkwrap":false,"_cnpm_publish_time":1370410273259,"_cnpmcore_publish_time":"2021-12-16T13:32:50.382Z"},"0.0.4":{"name":"date-extended","version":"0.0.4","description":"Additional date extensions with a chainable api","main":"index.js","scripts":{"test":"it -r dot"},"repository":{"type":"git","url":"git:git@github.com:doug-martin/date-extended.git"},"keywords":["Date","extender","utilities"],"testling":{"files":"test/browserling.js","browsers":["ie/6..latest","chrome/20..latest","firefox/14..latest","safari/latest","iphone/6","ipad/6"]},"author":{"name":"Doug Martin"},"license":"MIT","dependencies":{"extended":"~0.0.3","is-extended":"~0.0.3","array-extended":"~0.0.3","grunt-contrib-uglify":"~0.2.0","grunt":"~0.4.1","grunt-contrib-jshint":"~0.4.3"},"devDependencies":{"it":"~0.2.0","grunt-it":"~0.3.0"},"readmeFilename":"README.md","_id":"date-extended@0.0.4","dist":{"shasum":"cd6590a79d36bd008a0c112aba540bb881cee6b5","size":21927,"noattachment":false,"key":"/date-extended/-/date-extended-0.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/date-extended/download/date-extended-0.0.4.tgz"},"_from":".","_npmVersion":"1.2.17","_npmUser":{"name":"damartin","email":"doug@dougamartin.com"},"maintainers":[{"name":"damartin","email":"doug@dougamartin.com"}],"directories":{},"publish_time":1366127147219,"_hasShrinkwrap":false,"_cnpm_publish_time":1366127147219,"_cnpmcore_publish_time":"2021-12-16T13:32:50.775Z"},"0.0.3":{"name":"date-extended","version":"0.0.3","description":"Additional date extensions with a chainable api","main":"index.js","scripts":{"test":"it -r dot"},"repository":{"type":"git","url":"git:git@github.com:doug-martin/date-extended.git"},"keywords":["Date","extender","utilities"],"testling":{"files":"test/browserling.js","browsers":{"ie":[6,7,8,9],"chrome":[4,23,"canary"],"firefox":[3,3.5,3.6,4,17,"nightly"],"opera":[10,10.5,11,11.5,11.6,12,"next"],"safari":["5.0.1",5.1]}},"author":{"name":"Doug Martin"},"license":"MIT","dependencies":{"extended":"~0.0.3","is-extended":"~0.0.3","array-extended":"~0.0.3"},"devDependencies":{"it":"~0.2.0","grunt-it":"~0.2.1"},"readmeFilename":"README.md","_id":"date-extended@0.0.3","dist":{"shasum":"1d15a21ca0c4d0257f977be5aad596a8f73a3f49","size":22226,"noattachment":false,"key":"/date-extended/-/date-extended-0.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/date-extended/download/date-extended-0.0.3.tgz"},"_npmVersion":"1.2.0","_npmUser":{"name":"damartin","email":"doug@dougamartin.com"},"maintainers":[{"name":"damartin","email":"doug@dougamartin.com"}],"directories":{},"publish_time":1358838508299,"_hasShrinkwrap":false,"_cnpm_publish_time":1358838508299,"_cnpmcore_publish_time":"2021-12-16T13:32:51.043Z"},"0.0.2":{"name":"date-extended","version":"0.0.2","description":"Additional date extensions with a chainable api","main":"index.js","scripts":{"test":"it -r dot"},"repository":{"type":"git","url":"git:git@github.com:doug-martin/date-extended.git"},"keywords":["Date","extender","utilities"],"author":{"name":"Doug Martin"},"license":"MIT","dependencies":{"extended":"0.0.2","is-extended":"0.0.2","array-extended":"0.0.2"},"devDependencies":{"it":"~0.1.0","grunt-it":"~0.2.1"},"readmeFilename":"README.md","_id":"date-extended@0.0.2","dist":{"shasum":"f9fd920483f63446a4595423ba8002a07c052293","size":21971,"noattachment":false,"key":"/date-extended/-/date-extended-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/date-extended/download/date-extended-0.0.2.tgz"},"_npmVersion":"1.2.0","_npmUser":{"name":"damartin","email":"doug@dougamartin.com"},"maintainers":[{"name":"damartin","email":"doug@dougamartin.com"}],"directories":{},"publish_time":1358572031324,"_hasShrinkwrap":false,"_cnpm_publish_time":1358572031324,"_cnpmcore_publish_time":"2021-12-16T13:32:51.284Z"},"0.0.1":{"name":"date-extended","version":"0.0.1","description":"Additional date extensions with a chainable api","main":"index.js","scripts":{"test":"it -r dot"},"repository":{"type":"git","url":"git:git@github.com:doug-martin/date-extended.git"},"keywords":["Date","extender","utilities"],"author":{"name":"Doug Martin"},"license":"MIT","dependencies":{"extender":"0.0.4","is-extended":"0.0.1"},"devDependencies":{"it":"~0.1.0","grunt-it":"~0.3.0"},"readmeFilename":"README.md","_id":"date-extended@0.0.1","dist":{"shasum":"db61dd0384924e6321c322f2e88cb860e64a275b","size":21931,"noattachment":false,"key":"/date-extended/-/date-extended-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/date-extended/download/date-extended-0.0.1.tgz"},"_npmVersion":"1.2.0","_npmUser":{"name":"damartin","email":"doug@dougamartin.com"},"maintainers":[{"name":"damartin","email":"doug@dougamartin.com"}],"directories":{},"publish_time":1358371504796,"_hasShrinkwrap":false,"_cnpm_publish_time":1358371504796,"_cnpmcore_publish_time":"2021-12-16T13:32:51.562Z"}},"readme":"[![Build Status](https://travis-ci.org/doug-martin/date-extended.png?branch=master)]((https://travis-ci.org/doug-martin/date-extended)\n\n[![browser support](https://ci.testling.com/doug-martin/date-extended.png)](https://ci.testling.com/doug-martin/date-extended)\n\n# date-extended\n\n`date-extended` is a Javascript library that can be used standalone or incorporated into [`extended`](https://github.com/doug-martin/extended)\n\n```javascript\nvar date = require(\"date-extended\");\n```\n\nOr\n\n```javascript\nvar myextended = require(\"extended\")\n\t.register(require(\"date-extended\"));\n```\n\n## Installation\n\n```\nnpm install date-extended\n```\n\nOr [download the source](https://raw.github.com/doug-martin/date-extended/master/index.js) ([minified](https://raw.github.com/doug-martin/date-extended/master/date-extended.min.js))\n\n## Usage\n\n\n**`getDaysInMonth`**\n\nReturns the number of days in the month of a date\n\n```javascript\n\n date.getDaysInMonth(new Date(2006, 1, 1)); //28\n date.getDaysInMonth(new Date(2004, 1, 1)); //29\n date.getDaysInMonth(new Date(2006, 2, 1)); //31\n date.getDaysInMonth(new Date(2006, 3, 1)); //30\n\n\n date(new Date(2006, 4, 1)).getDaysInMonth().value(); //31\n date(new Date(2006, 5, 1)).getDaysInMonth().value(); //30\n date(new Date(2006, 6, 1)).getDaysInMonth(); //31\n```\n\n**`isLeapYear`**\n\nDetermines if a date is a leap year\n\n```javascript\n\n date.isLeapYear(new Date(1600, 0, 1)); //true\n date.isLeapYear(new Date(2006, 0, 1)); //false\n date.isLeapYear(new Date(2004, 0, 1)); //true\n\n date(new Date(1900, 0, 1)).isLeapYear(); //false\n date(new Date(2000, 0, 1)).isLeapYear(); //true\n date(new Date(1800, 0, 1)).isLeapYear(); //false\n```\n\n**`isWeekend`**\n\nDetermines if a date is on a weekend\n\n```javascript\n\nvar thursday = new Date(2006, 8, 21);\ndate.isWeekend(thursday)); //false\n\nvar saturday = new Date(2006, 8, 23);\ndate(saturday).isWeekend(); //true\n\nvar sunday = new Date(2006, 8, 24);\ndate.isWeekend(sunday); //true\n\nvar monday = new Date(2006, 8, 25);\ndate(monday).isWeekend()); //false\n```\n\n**`getTimezoneName`**\nGet the timezone of a date\n\n**`compare`**\nCompares two dates\n\n```javascript\n\nvar d1 = new Date();\nd1.setHours(0);\ndate.compare(d1, d1); // 0\n\nvar d1 = new Date(), d2 = new Date();\nd1.setHours(0);\nd2.setFullYear(2005);\nd2.setHours(12);\n\ndate.compare(d1, d2, \"date\"); // 1\ndate(d1).compare(d2, \"datetime\"); // 1\n\nvar d1 = new Date(), d2 = new Date();\nd1.setHours(0);\nd2.setFullYear(2005);\nd2.setHours(12);\n\ndate(d2).compare(d1, \"date\"); // -1\ndate(d1).compare(d2, \"time\"); //-1\n```\n\n**`add`**\n\nAdds a specified interval and amount to a date\n\n * day | days\n * weekday | weekdays\n * year | years\n * week | weeks\n * quarter | quarters\n * months | months\n * hour | hours\n * minute | minutes\n * second | seconds\n * millisecond | milliseconds\n\n```javascript\nvar dtA = new Date(2005, 11, 27);\ndate.add(dtA, \"year\", 1); //new Date(2006, 11, 27);\ndate(dtA).add(\"years\", 1).value(); //new Date(2006, 11, 27);\n\ndtA = new Date(2000, 0, 1);\ndate.add(dtA, \"quarter\", 1); //new Date(2000, 3, 1);\ndate(dtA).add(\"quarters\", 1).value(); //new Date(2000, 3, 1);\n\ndtA = new Date(2000, 0, 1);\ndate.add(dtA, \"month\", 1); //new Date(2000, 1, 1);\ndate(dtA).add(\"months\", 1).value(); //new Date(2000, 1, 1);\n\ndtA = new Date(2000, 0, 31);\ndate.add(dtA, \"month\", 1); //new Date(2000, 1, 29);\ndate(dtA).add(\"months\", 1).value(); //new Date(2000, 1, 29);\n\ndtA = new Date(2000, 0, 1);\ndate.add(dtA, \"week\", 1); //new Date(2000, 0, 8);\ndate(dtA).add(\"weeks\", 1).value(); //new Date(2000, 0, 8);\n\ndtA = new Date(2000, 0, 1);\ndate(dtA).add(\"day\", 1).value(); //new Date(2000, 0, 2);\n\ndtA = new Date(2000, 0, 1);\ndate(dtA).add(\"weekday\", 1); //new Date(2000, 0, 3);\n\ndtA = new Date(2000, 0, 1, 11);\ndate(dtA).add(\"hour\", 1).value(); //new Date(2000, 0, 1, 12);\n\ndtA = new Date(2000, 11, 31, 23, 59);\ndate.add(dtA, \"minute\", 1); //new Date(2001, 0, 1, 0, 0);\n\ndtA = new Date(2000, 11, 31, 23, 59, 59);\ndate.add(dtA, \"second\", 1); //new Date(2001, 0, 1, 0, 0, 0);\n\ndtA = new Date(2000, 11, 31, 23, 59, 59, 999);\ndate.add(dtA, \"millisecond\", 1); //new Date(2001, 0, 1, 0, 0, 0, 0);\n```\n\n**`difference`**\n\nFinds the difference between two dates based on the specified interval\n\n * day | days\n * weekday | weekdays\n * year | years\n * week | weeks\n * quarter | quarters\n * months | months\n * hour | hours\n * minute | minutes\n * second | seconds\n * millisecond | milliseconds\n\n```javascript\n\nvar dtA, dtB;\n\ndtA = new Date(2005, 11, 27);\ndtB = new Date(2006, 11, 27);\ndate.difference(dtA, dtB, \"year\"); //1\n\ndtA = new Date(2000, 1, 29);\ndtB = new Date(2001, 2, 1);\ndate.difference(dtA, dtB, \"quarter\"); //4\ndate(dtA).difference(dtB, \"month\").value(); //13\n\ndtA = new Date(2000, 1, 1);\ndtB = new Date(2000, 1, 8);\ndate.difference(dtA, dtB, \"week\"); //1\n\ndtA = new Date(2000, 1, 29);\ndtB = new Date(2000, 2, 1);\ndate(dtA).difference(dtB, \"day\").value(); //1\n\ndtA = new Date(2006, 7, 3);\ndtB = new Date(2006, 7, 11);\ndate.difference(dtA, dtB, \"weekday\"); //6\n\ndtA = new Date(2000, 11, 31, 23);\ndtB = new Date(2001, 0, 1, 0);\ndate(dtA).difference(dtB, \"hour\").value(); //1\n\ndtA = new Date(2000, 11, 31, 23, 59);\ndtB = new Date(2001, 0, 1, 0, 0);\ndate.difference(dtA, dtB, \"minute\"); //1\n\ndtA = new Date(2000, 11, 31, 23, 59, 59);\ndtB = new Date(2001, 0, 1, 0, 0, 0);\ndate(dtA).difference(dtB, \"second\").value(); //1\n\ndtA = new Date(2000, 11, 31, 23, 59, 59, 999);\ndtB = new Date(2001, 0, 1, 0, 0, 0, 0);\ndate.difference(dtA, dtB, \"millisecond\"); //1\n````\n\n\n**`format`**\n\nFormats a date to the specified format string\n\n * `G`    Era designator    Text    AD\n * `y`    Year    Year    1996; 96\n * `M`    Month in year    Month    July; Jul; 07\n * `w`    Week in year    Number    27\n * `W`    Week in month    Number    2\n * `D`    Day in year    Number    189\n * `d`    Day in month    Number    10\n * `E`    Day in week    Text    Tuesday; Tue\n * `a`    Am/pm marker    Text    PM\n * `H`    Hour in day (0-23)    Number    0\n * `k`    Hour in day (1-24)    Number    24\n * `K`    Hour in am/pm (0-11)    Number    0\n * `h`    Hour in am/pm (1-12)    Number    12\n * `m`    Minute in hour    Number    30\n * `s`    Second in minute    Number    55\n * `S`    Millisecond    Number    978\n * `z`    Time zone    General time zone    Pacific Standard Time; PST; GMT-08:00\n * `Z`    Time zone    RFC 822 time zone    -0800 \n\n```javascript\nvar date = new Date(2006, 7, 11, 0, 55, 12, 345);\ndate.format(date, \"EEEE, MMMM dd, yyyy\"); //\"Friday, August 11, 2006\"\ndate(date).format(\"M/dd/yy\").value(); //\"8/11/06\"\ndate.format(date, \"E\"); //\"6\"\ndate(date).format(\"h:m a\").value(); //\"12:55 AM\"\ndate.format(date, 'h:m:s'); //\"12:55:12\"\ndate(date).format('h:m:s.SS').value(); //\"12:55:12.35\"\ndate.format(date, 'k:m:s.SS'); //\"24:55:12.35\"\ndate(date).format('H:m:s.SS').value(); //\"0:55:12.35\"\ndate.format(date, \"ddMMyyyy\"); //\"11082006\"\n```\n\n**`parseDate`**\n\nParses a date string into a date object\n\n * `G`    Era designator    Text    AD\n * `y`    Year    Year    1996; 96\n * `M`    Month in year    Month    July; Jul; 07\n * `w`    Week in year    Number    27\n * `W`    Week in month    Number    2\n * `D`    Day in year    Number    189\n * `d`    Day in month    Number    10\n * `E`    Day in week    Text    Tuesday; Tue\n * `a`    Am/pm marker    Text    PM\n * `H`    Hour in day (0-23)    Number    0\n * `k`    Hour in day (1-24)    Number    24\n * `K`    Hour in am/pm (0-11)    Number    0\n * `h`    Hour in am/pm (1-12)    Number    12\n * `m`    Minute in hour    Number    30\n * `s`    Second in minute    Number    55\n * `S`    Millisecond    Number    978\n * `z`    Time zone    General time zone    Pacific Standard Time; PST; GMT-08:00\n * `Z`    Time zone    RFC 822 time zone    -0800\n\n```javascript\n var aug_11_2006 = new Date(2006, 7, 11, 0);\n date.parse(\"08/11/06\", \"MM/dd/yy\"); //aug_11_2006\n date.parse(\"11Aug2006\", 'ddMMMyyyy'); //aug_11_2006\n date.parse(\"Aug2006\", 'MMMyyyy'); //new Date(2006, 7, 1)\n date.parse(\"Aug 11, 2006\", \"MMM dd, yyyy\"); //aug_11_2006\n date.parse(\"August 11, 2006\", \"MMMM dd, yyyy\"); //aug_11_2006\n date.parse(\"Friday, August 11, 2006\", \"EEEE, MMMM dd, yyyy\"); //aug_11_2006\n```\n\n\n\n**FromNow and Ago**\n\nThe following are convenience methods for adding ad subtracting intervals from the current date.\n\n* `yearsFromNow` \n* `yearsAgo`\n* `monthsFromNow`\n* `monthsAgo`\n* `daysFromNow`\n* `daysAgo`\n* `hoursFromNow`\n* `hoursAgo`\n* `minutesFromNow`\n* `minutesAgo`\n* `secondsFromNow`\n* `secondsAgo`\n\n```javascript\n//two years ago\ndate(2).yearsAgo();\ndate.yearsAgo(2)\n\n//five hours from now\ndate(5).hoursFromNow();\ndate.hoursFromNow(5);\n\n//two seconds ago\ndate(2).secondsAgo();\ndate.secondsAgo(2)\n```","_attachments":{},"homepage":"https://github.com/doug-martin/date-extended","bugs":{"url":"https://github.com/doug-martin/date-extended/issues"},"license":"MIT"}