{"dist":{"shasum":"3423a86a0785bc82bc86d0177578b5222cb23995","tarball":"https://registry.npmjs.org/d8/-/d8-0.3.5.tgz","integrity":"sha512-FchxsVTV5qs0Gp28e2t39HAXZBOY2gTXrtivEgl49SmVM4cWFiQCohFufVkLymCM5PyqnD3quXS11s4EGk5Nbg==","signatures":[{"sig":"MEUCIFPJ82aDElEMt/L4jKTrQgEUx6T1tNE3AidMr9J0zaqoAiEA9RJaG7Z0jUqf9ndqrLmB0a4puV7EgiX9osQIUv81kv4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./d8.js","name":"d8","author":{"url":"http://muigui.com","name":"constantology","email":"christos@muigui.com"},"readme":"<!-- [![build status](https://secure.travis-ci.org/constantology/d8.png)](http://travis-ci.org/constantology/d8) -->\n# d8.js\n\nd8 is a date parsing and formatting micro-framework for modern JavaScript engines.\n\nd8 formats Dates into Strings and conversley turns Strings into Dates based on [php formatting options](http://php.net/manual/en/function.date.php).\n\nAs d8 extends JavaScript's native `Date` & `Date.prototype` – the CORRECT way – there is no actual global called d8. Instead all static and instance methods are available on the native `Date` & `Date.prototype` respectively.\n\ncurrently the only locales available are:\n\n- en-GB (0.6kb deflated)\n- en-US (0.6kb deflated)\n\nbut feel free to create a locale for your specific nationality and submit a pull request! :D\n\n## Dependencies\n\nd8.js only has one dependency [m8.js](/constantology/m8).\n\n**NOTE:**\nIf you are using d8 within a commonjs module, you don't need to require m8 before requiring d8 as this is done internally.\n\nAlso, since d8.js simply extends the Native Date Class, a reference to **m8 IS NOT** stored.\n\n## browser usage\n\n```html\n\n   <script src=\"/path/to/m8/m8.js\" type=\"text/javascript\"></script>\n\n<!-- IMPORTANT: The correct locale must be loaded before d8! -->\n   <script src=\"/path/to/d8/locale/en-GB.js\" type=\"text/javascript\"></script>\n   <script src=\"/path/to/d8/d8.min.js\" type=\"text/javascript\"></script>\n\n```\n\n## nodejs usage\n\n```javascript\n\n   require( 'd8/locale/en-GB' ); // IMPORTANT: The correct locale must be loaded before d8!!\n   require( 'd8' );\n\n// if running in a sandboxed environment remember to:\n   require( 'm8' ).x( Date ); // and/ or any other Types that require extending.\n\n```\n\nAs mentioned above d8 extends JavaScript's native `Date` & `Date.prototype`, so when requiring d8, you don't need to assign it to a variable to use d8's features.\n\n## Support\n\nTested to work with nodejs, FF4+, Safari 5+, Chrome 7+, IE9+. Should technically work in any browser that supports [ecma 5]( http://kangax.github.com/es5-compat-table/) without throwing any JavaScript errors.\n\n## API\n\n### Static methods\n\n#### isLeapYear( year:String ):Boolean\nReturns true if the passed **4 digit** year is a leap year.\n\n**NOTE:** This method is located in the locale file. If your calendar system does not contain leap years, you can simply change the method to only `return false`.\n\n#### getOrdinal( date:Number ):String\nReturns the ordinal for a given date.\n\n##### Example:\n\n```javascript\n\n   Date.getOrdinal( 1 );  // returns => \"st\"\n   Date.getOrdinal( 10 ); // returns => \"th\"\n   Date.getOrdinal( 22 ); // returns => \"nd\"\n   Date.getOrdinal( 33 ); // returns => \"rd\"\n\n```\n\n**NOTE:** Ordinals and the `getOrdinal` This method is located in the locale file. You can simply change the `ordinal` Array to your specific language; overwrite the `getOrdinal` method or both.\n\n#### setLeapYear( date:Date ):Void\nSets the inlcuded locale's February day count to the correct number of days, based on whether or not the date is a leap year or not.\n\n**NOTE:** This method is located in the locale file. If your calendar system does not contain leap years, you can simply change the method to do nothing.\n\n#### toDate( date:String, format:String ):Date\nTakes a date String and a format String based on the **Date formatting and parsing options** described below and returns a – hopefully – correct and valid Date.\n\n```javascript\n\n   Date.toDate( 'Sunday, the 1st of January 2012', 'l, <the> jS <of> F Y' ); // returns => Date { Sun Jan 01 2012 00:00:00 GMT+0000 (GMT) }\n   Date.toDate( '2012-01-01T00:00:00+00:00',        Date.formats.ISO_8601 ); // returns => Date { Sun Jan 01 2012 00:00:00 GMT+0000 (GMT) }\n\n```\n\n### Static properties\n\n#### filters\nAn Object of all the available filters for formatting a Date.\n\n**IMPORTANT: Don't change these unless you know what you are doing!**\n\n#### formats\nAn Object containing some default date formats:\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n\t<tr><td width=\"96\">ISO_8601</td><td>Y-m-d<T>H:i:sP</td>\n\t<tr><td width=\"96\">ISO_8601_SHORT</td><td>Y-m-d</td>\n\t<tr><td width=\"96\">RFC_850</td><td>l, d-M-y H:i:s T</td>\n\t<tr><td width=\"96\">RFC_2822</td><td>D, d M Y H:i:s O</td>\n\t<tr><td width=\"96\">sortable</td><td>Y-m-d H:i:sO</td>\n</table>\n\n### Instance methods\n\n#### adjust( interval:Object|String[, value:Number] ):Date\nYour one stop shop for all Date arithmetic. Adjusts the Date based on the passed `interval`, by the passed numeric `value`.\n\n**Note:** The method also accepts a single Object param where each key is the interval and each value is the number to adjust the Date by.\n\n**Valid intervals are:** year, month, week, day, hr, min, sec, ms.\n\n##### Example:\n\n```javascript\n\n   var date = new Date( 2012, 0, 1 ); // Date {Sun Jan 01 2012 00:00:00 GMT+0000 (GMT)}\n\n   date.adjust( Date.DAY,   1 );      // Date {Mon Jan 02 2012 00:00:00 GMT+0000 (GMT)}\n   date.adjust( Date.HOUR, -1 );      // Date {Sun Jan 01 2012 23:00:00 GMT+0000 (GMT)}\n   date.adjust( {\n      year : -1, month : -1, day : 24,\n      hr   :  1, sec   : -1\n   } );                               // Date {Sat Dec 25 2010 23:59:59 GMT+0000 (GMT)}\n\n```\n\n#### between( date_lower:Date, date_higher:Date ):Boolean\nChecks to see if the Date instance is in between the two passed Dates.\n\n#### clearTime():Date\nClears the time from the Date instance.\n\n#### clone():Date\nReturns a clone of the current Date.\n\n#### format( format:String ):String\nReturns a string representation of the Date instance, based on the passed format. See the **Date formatting and parsing options** below.\n\nYou can use predefined formats found in `Date.formats`. **Hint:** You can do:\n\n```javascript\n\n   console.dir( Date.formats );\n\n```\n\nwithin your browser's JavaScript console to see a list of available formats.\n\nPreviously used formats are also cached to save the overhead of having to create a `new Function` everytime you want to format a date.\n\n#### getDayOfYear():Number\nReturns the zero based day of the year.\n\n#### getFirstOfTheMonth():Date\nReturns a Date instance of the first day of this Date instance's month.\n\n#### getGMTOffset( [colon:Boolean] ):String\nReturns the Date instances offset from GMT.\n\n#### getISODay():Number\nReturns the ISO day of the week.\n\n#### getISODaysInYear():Number\nReturns the ISO number of days in the year.\n\n#### getISOFirstMondayOfYear():Date\nReturns the ISO first Monday of the year.\n\n#### getISOWeek():Number\nReturns the ISO week of the year\n\n#### getISOWeeksInYear():Number\nReturns the number of weeks in the ISO year.\n\n#### getLastOfTheMonth():Date\nReturns a Date instance of the last day of this Date instance's month.\n\n#### getWeek():Number\nReturns the week of the year, based on the `dayOfYear` divided by 7.\n\n##### Example:\n\n```javascript\n\n   ( new Date( 2012, 0, 1 ) ).getWeek();   // returns => 0\n   ( new Date( 2012, 2, 13 ) ).getWeek();  // returns => 10\n   ( new Date( 2012, 11, 31 ) ).getWeek(); // returns => 52\n\n```\n\n#### isDST():Boolean\nReturns true if the Date instance is within daylight savings time.\n\n#### isLeapYear():Boolean\nReturns true if the Date instance is a leap year.\n\n#### setWeek():Number(UnixTimeStamp)\nSets the week of the year from the 1st January.\n\n##### Example:\n\n```javascript\n\n   new Date( ( new Date( 2012, 0, 1 ) ).setWeek( 17 ) ); // returns => Date {Sun Apr 29 2012 00:00:00 GMT+0100 (BST)}\n   ( new Date( 2012, 2, 13 ) ).setWeek( 17 );            // returns => 1335654000000 same as above\n   ( new Date( 2012, 11, 31 ) ).setWeek( 17 );           // returns => 1335654000000\n\n```\n\n#### timezone():String\nReturns the JavaScript engine's Date.prototype.toString() timezone abbreviation.\n\n## Date formatting and parsing options\n\n### escaping characters\n\nIf you want to escape characters that are used by the Date parser you can wrap them between &lt;&gt;.\n\n#### Example:\n\n```javascript\n\n   ( new Date( 2012, 0, 1 ) ).format( 'l, <the> jS <of> F Y' ); // returns => \"Sunday, the 1st of January 2012\"\n\n```\n\n### day\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n\t<tr><td width=\"32\">d</td><td>Day of the month, 2 digits with leading zeros</td>\n\t<tr><td width=\"32\">D</td><td>A textual representation of a day, three letters</td>\n\t<tr><td width=\"32\">j</td><td>Day of the month without leading zeros</td>\n\t<tr><td width=\"32\">l</td><td>A full textual representation of the day of the week</td>\n\t<tr><td width=\"32\">N</td><td>ISO-8601 numeric representation of the day of the week</td>\n\t<tr><td width=\"32\">S</td><td>English ordinal suffix for the day of the month, 2 characters</td>\n\t<tr><td width=\"32\">w</td><td>Numeric representation of the day of the week</td>\n\t<tr><td width=\"32\">z</td><td>The day of the year (starting from 0)</td>\n</table>\n### week\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n\t<tr><td width=\"32\">W</td><td>ISO-8601 week number of year, weeks starting on Monday</td>\n</table>\n### month\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n\t<tr><td width=\"32\">F</td><td>A full textual representation of a month</td>\n\t<tr><td width=\"32\">m</td><td>Numeric representation of a month, with leading zeros</td>\n\t<tr><td width=\"32\">M</td><td>A short textual representation of a month, three letters</td>\n\t<tr><td width=\"32\">n</td><td>Numeric representation of a month, without leading zeros</td>\n\t<tr><td width=\"32\">t</td><td>Number of days in the given month</td>\n</table>\n### year\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n\t<tr><td width=\"32\">L</td><td>Whether it's a leap year</td>\n\t<tr><td width=\"32\">o</td><td>ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.</td>\n\t<tr><td width=\"32\">Y</td><td>A full numeric representation of a year, 4 digits</td>\n\t<tr><td width=\"32\">y</td><td>A two digit representation of a year</td>\n</table>\n### time\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n\t<tr><td width=\"32\">a</td><td>Lowercase Ante meridiem and Post meridiem</td>\n\t<tr><td width=\"32\">A</td><td>Uppercase Ante meridiem and Post meridiem</td>\n\t<tr><td width=\"32\">g</td><td>12-hour format of an hour without leading zeros</td>\n\t<tr><td width=\"32\">G</td><td>24-hour format of an hour without leading zeros</td>\n\t<tr><td width=\"32\">h</td><td>12-hour format of an hour with leading zeros</td>\n\t<tr><td width=\"32\">H</td><td>24-hour format of an hour with leading zeros</td>\n\t<tr><td width=\"32\">i</td><td>Minutes with leading zeros</td>\n\t<tr><td width=\"32\">s</td><td>Seconds, with leading zeros</td>\n\t<tr><td width=\"32\">u</td><td>Milliseconds</td>\n</table>\n### timezone\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n\t<tr><td width=\"32\">O</td><td>Difference to Greenwich time (GMT) in hours</td>\n\t<tr><td width=\"32\">P</td><td>Difference to Greenwich time (GMT) with colon between hours and minutes</td>\n\t<tr><td width=\"32\">T</td><td>Timezone abbreviation</td>\n\t<tr><td width=\"32\">Z</td><td>Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.</td>\n</table>\n### full date/time\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n\t<tr><td width=\"32\">c</td><td>ISO 8601 date</td>\n\t<tr><td width=\"32\">r</td><td>RFC 2822 formatted date</td>\n\t<tr><td width=\"32\">U</td><td>Seconds since the Unix Epoch January 1 1970 00:00:00 GMT</td>\n</table>\n\n## License\n\n(The MIT License)\n\nCopyright &copy; 2012 christos \"constantology\" constandinou http://muigui.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","engines":{"node":">= 0.4.x"},"scripts":{"test":"mocha -c --ignore-leaks -R spec -u tdd ./test/*.test.js"},"_npmUser":{"name":"constantology","email":"constantology@gmail.com"},"keywords":["date"],"licenses":[{"url":"https://raw.github.com/constantology/d8/master/LICENSE","type":"MIT"}],"repository":{"url":"git@github.com:constantology/d8.git","type":"git"},"_npmVersion":"1.1.59","description":"d8 is a date parsing and formatting micro-framework for modern JavaScript engines.","directories":{},"maintainers":[{"name":"constantology","email":"constantology@gmail.com"}],"dependencies":{"m8":">= 0.1.0"},"devDependencies":{"chai":">= 1.2.0","mocha":">= 1.3.0","Templ8":">= 0.3.0","mkdirp":">= 0.3.0","uglify-js":">= 1.2.5"},"_id":"d8@0.3.5","version":"0.3.5"}