]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Finishing docs and updating readme for 1.0.0 release
authorTim Wood <washwithcare@gmail.com>
Mon, 17 Oct 2011 19:58:01 +0000 (12:58 -0700)
committerTim Wood <washwithcare@gmail.com>
Mon, 17 Oct 2011 19:58:01 +0000 (12:58 -0700)
README.markdown
build.js
docs/index.html
moment.js
moment.min.js

index 606b105ff85a25ff95b63e1f522be8540d2e0f86..cdf90e622fb209bea71e5cd58308bdb3bdc3cbb2 100755 (executable)
-Moment
-======
+Moment.js
+=========
 
-Moment is a javascript date library that helps create, manipulate, and format dates without extending the `Date` prototype.
+Moment.js is a javascript date library that helps create, manipulate, and format dates without extending the `Date` prototype.
 
 Author: Tim Wood
 
-Version: 0.7.0
+Version: 1.0.0
 
 ### 2.2 kb (min + gzip)
 
-Where to use it
-===============
-
-### Node.js
-
-Install with npm
-
     npm install underscore.date
 
-Usage
-
-    var _date = require('underscore.date');
-    console.log(_date('September 9 1999').fromNow());
-
-### In the browser
-
-If underscore exists, underscore.date will mix itself into the underscore namespace, so you can use as you would use an underscore function.
-
-    _.date('September 9 1999').fromNow();
-    
-Otherwise, you should use `_date`.
-
-    _date('September 9 1999').fromNow();
-    
-_date() 
-=======
-
-The library works by creating a `_date()` wrapper object. To create that wrapper, you can pass any of the following data types in.
-
-
-
-### Number
-
-    _date(1300291340510)
-
-An integer value representing the number of milliseconds since 1 January 1970 00:00:00 UTC.
-
-
-
-### Date 
-
-    _date(new Date(2010, 1, 14, 15, 25, 50, 125))
-
-Any valid `Date` object. For more information on `Date` objects, see [the JavaScript Date documentation at MDN](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date)
-
-
-
-
-### Array
-
-    _date([2010, 1, 14, 15, 25, 50, 125])
-
-An array mirroring the parameters passed into [Date.UTC()](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/UTC).
-
-`[year, month = 0, date = 1, hours = 0, minutes = 0, seconds = 0, milliseconds = 0]`
-
-Any value past the year is optional, and will default to the lowest possible number.
-
-
-
-### undefined
-
-    _date()
-
-If no value is passed to a 'dateInput' parameter, it will default to the current time using `new Date()`.
-
-    _date() === _date(new Date())
-
-
-
-
-### String
-
-    _date("Dec 25, 1995")
-A string that can be parsed by [Date.parse()](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/parse).
-
-
-
-### String with format
-
-    _date("12-25-1995", "MM-DD-YYYY")
-A string and a format string. The second string will be used as the format to parse the first string.
-
-The format parts are similar to the formats from _date().format()
-
-**Important:** Parsing a string with a format is by far the slowest method of creating a date. 
-If you have the ability to change the input, it is much faster (~15x) to use Unix timestamps.
-
-NOTE: The parser ignores non-alphanumeric characters, so both `_date("12-25-1995", "MM-DD-YYYY")` and
-`_date("12\25\1995", "MM-DD-YYYY")` will return the same thing.
-
-
-<table>
-    <tr>
-        <th>Input</th>
-        <th>Output</th>
-    </tr>
-    <tr>
-        <td>M or MM</td>
-        <td>Month</td>
-    </tr>
-    <tr>
-        <td>D or DD</td>
-        <td>Day of month</td>
-    </tr>
-    <tr>
-        <td>DDD or DDDD</td>
-        <td>Day of year</td>
-    </tr>
-    <tr>
-        <td>YY</td>
-        <td>2 digit year (if greater than 70, will return 1900's, else 2000's)</td>
-    </tr>
-    <tr>
-        <td>YYYY</td>
-        <td>4 digit year</td>
-    </tr>
-    <tr>
-        <td>a or A</td>
-        <td>AM/PM</td>
-    </tr>
-    <tr>
-        <td>H, HH, h, or hh</td>
-        <td>24 hour (for 12 hour time, use in conjunction with a or A)</td>
-    </tr>
-    <tr>
-        <td>m or mm</td>
-        <td>Minutes</td>
-    </tr>
-    <tr>
-        <td>s or ss</td>
-        <td>Seconds</td>
-    </tr>
-</table>
-
-
-### String with array of formats
-
-    _date("12-25-1995", ["MM-DD-YYYY", "YYYY-MM-DD"])
-
-A list of format strings to try to parse the input string.
-
-This will find the format that is closest to the input formats. This is fundamentally problematic in cases like the following.
-
-    _date("05-06-1995", ["MM-DD-YYYY", "DD-MM-YYYY"]) // June 5th or May 6th?
-
-Ideally, you should stick to one input format for creating dates.
-
-**Important:** THIS IS SLOW. This should only be used as a last line of defense. Check out the comparisons at
-http://jsperf.com/underscore-date/2 if you don't believe me. It's the one on the bar graph that you can't even see, that's
-how slow it is.
-
-_date Prototype
-===============
-
-`underscore.date` contains a number of utility functions for manipulating and formatting dates.
-
-
-_date.add()
------------
-
-    _date.add(object)
-
-Adds time per the object passed in.
-
-The object should have key value pairs as shown below.
-
-    {
-        ms : 200, // milliseconds
-        s : 10,   // seconds
-        m : 10,   // minutes (note: lowercase)
-        h : 2,    // hours
-        d : 3,    // days
-        M : 2,    // months (note: uppercase)
-        y : 3     // years
-    }
-
-All the parameters are optional. Also, there are no upper limits for the values, so you can overload any of the parameters.
-
-    { ms : 1000000 } // a million milliseconds
-    { d : 360 }      // 360 days
-
-### Special considerations for months and years
-
-If the day of the month on the original date is greater than the number of days in the final month, the day of the month will change to the last day in the final month.
-
-Example:
-    
-    _date([2010, 0, 31])              // January 31
-    _date([2010, 0, 31]).add({M : 1}) // February 28
-    
-    
-_date.subtract()
-----------------
-
-    _date.subtract(object)
-
-Functions the same as `_date.add()`, only using subtraction instead of addition.
-
-Example:
-    
-    _date([2010, 1, 28])                 // February 28
-    _date([2010, 1, 28]).subtract({M:1}) // January 28
-  
-
-  
-_date.format()
---------------
-
-    _date.format(string)
-
-Returns a human readable string based on the format string that was passed in.
-
-    var dateToFormat = new Date(2010, 1, 14, 15, 25, 50, 125);
-    _date(dateToFormat).format("dddd, MMMM Do YYYY, h:mm:ss a"); // "Sunday, February 14th 2010, 3:25:50 pm"
-    _date(dateToFormat).format("ddd, hA");                       // "Sun, 3PM"
-
-The formats are created by creating a string of replacable characters.
-
-<table>
-    <tr>
-        <th>Input</th>
-        <th>Output</th>
-    </tr>
-    <tr>
-       <td><b>Month</b></td>
-        <td></td>
-    </tr>
-    <tr>
-        <td>M</td>
-        <td>1 2 ... 11 12</td>
-    </tr>
-    <tr>
-        <td>Mo</td>
-        <td>1st 2nd ... 11th 12th</td>
-    </tr>
-    <tr>
-        <td>MM</td>
-        <td>01 02 ... 11 12</td>
-    </tr>
-    <tr>
-        <td>MMM</td>
-        <td>Jan Feb ... Nov Dec</td>
-    </tr>
-    <tr>
-        <td>MMMM</td>
-        <td>January February ... November December</td>
-    </tr>
-    <tr>
-       <td><b>Day&nbsp;of&nbsp;Month</b></td>
-        <td></td>
-    </tr>
-    <tr>
-        <td>D</td>
-        <td>1 2 ... 30 30</td>
-    </tr>
-    <tr>
-        <td>Do</td>
-        <td>1st 2nd ... 30th 31st</td>
-    </tr>
-    <tr>
-        <td>DD</td>
-        <td>01 02 ... 30 31</td>
-    </tr>
-    <tr>
-       <td><b>Day&nbsp;of&nbsp;Year</b></td>
-        <td></td>
-    </tr>
-    <tr>
-        <td>DDD</td>
-        <td>1 2 ... 364 365</td>
-    </tr>
-    <tr>
-        <td>DDDo</td>
-        <td>1st 2nd ... 364th 365th</td>
-    </tr>
-    <tr>
-        <td>DDDD</td>
-        <td>001 002 ... 364 365</td>
-    </tr>
-    <tr>
-       <td><b>Day&nbsp;of&nbsp;Week</b></td>
-        <td></td>
-    </tr>
-    <tr>
-        <td>d</td>
-        <td>0 1 ... 5 6</td>
-    </tr>
-    <tr>
-        <td>do</td>
-        <td>0th 1st ... 5th 6th</td>
-    </tr>
-    <tr>
-        <td>ddd</td>
-        <td>Sun Mon ... Fri Sat</td>
-    </tr>
-    <tr>
-        <td>dddd</td>
-        <td>Sunday Monday ... Friday Saturday</td>
-    </tr>
-    <tr>
-       <td><b>Week&nbsp;of&nbsp;Year</b></td>
-        <td></td>
-    </tr>
-    <tr>
-        <td>w</td>
-        <td>1 2 ... 52 53</td>
-    </tr>
-    <tr>
-        <td>wo</td>
-        <td>1st 2nd ... 52nd 53rd</td>
-    </tr>
-    <tr>
-        <td>ww</td>
-        <td>01 02 ... 52 53</td>
-    </tr>
-    <tr>
-       <td><b>Year</b></td>
-        <td></td>
-    </tr>
-    <tr>
-        <td>YY</td>
-        <td>70 71 ... 29 30</td>
-    </tr>
-    <tr>
-        <td>YYYY</td>
-        <td>1970 1971 ... 2029 2030</td>
-    </tr>
-    <tr>
-       <td><b>AM/PM</b></td>
-        <td></td>
-    </tr>
-    <tr>
-        <td>A</td>
-        <td>AM PM</td>
-    </tr>
-    <tr>
-        <td>a</td>
-        <td>am pm</td>
-    </tr>
-    <tr>
-       <td><b>Hour</b></td>
-        <td></td>
-    </tr>
-    <tr>
-        <td>H</td>
-        <td>0 1 ... 22 23</td>
-    </tr>
-    <tr>
-        <td>HH</td>
-        <td>00 01 ... 22 23</td>
-    </tr>
-    <tr>
-        <td>h</td>
-        <td>1 2 ... 11 12</td>
-    </tr>
-    <tr>
-        <td>hh</td>
-        <td>01 02 ... 11 12</td>
-    </tr>
-    <tr>
-       <td><b>Minute</b></td>
-        <td></td>
-    </tr>
-    <tr>
-        <td>m</td>
-        <td>0 1 ... 58 59</td>
-    </tr>
-    <tr>
-        <td>mm</td>
-        <td>00 01 ... 58 59</td>
-    </tr>
-    <tr>
-       <td><b>Second</b></td>
-        <td></td>
-    </tr>
-    <tr>
-        <td>s</td>
-        <td>0 1 ... 58 59</td>
-    </tr>
-    <tr>
-        <td>ss</td>
-        <td>00 01 ... 58 59</td>
-    </tr>
-    <tr>
-       <td><b>Timezone</b></td>
-        <td></td>
-    </tr>
-    <tr>
-        <td>z</td>
-        <td>EST CST ... MST PST</td>
-    </tr>
-    <tr>
-        <td>zz</td>
-        <td>
-            Eastern Standard Time ... Pacific Standard Time<br/><br/>
-            <small>
-            NOTE: Internet Explorer uses a different implementation of 
-            Date.toString(), so we are unable to retrieve the full string 
-            of the timezone, and will fall back to 'z'.<br/><br/>
-            So:<br/>
-            Firefox, Chrome, Safari, etc. == 'Eastern Standard Time'<br/>
-            Internet Explorer, etc. == 'EST'
-            </small>
-        </td>
-    </tr>
-</table>
-
-
-
-_date.from()
-------------
-
-    _date.from(date, withoutSuffix:boolean, asMilliseconds:boolean)
-
-Returns a string as relative time ('minutes ago', '5 months ago', etc).
-
-You can pass anything that you would pass to _date() as the first parameter, or a `_date()` object.
-
-    _date([2007, 0, 29]).from(_date([2007, 0, 28])) // "a day ago"
-    
-You can pass `true` as the second parameter to return without the prefixes and suffixes.
-
-    _date([2007, 0, 29]).from(_date([2007, 0, 28]), true) // "a day"
-    
-You can pass `true` as the third parameter to return as milliseconds. 
-The number of milliseconds returned will be positive if the date passed 
-in is later than the first date, and negative if the date passed in is earlier.
-
-    _date([2007, 0, 29]).from(_date([2007, 0, 28]), true , true) // -86400000);
-    _date([2007, 0, 27]).from(_date([2007, 0, 28]), true , true) // 86400000);
-
-The base strings for this function can be customized with `_date.relativeTime`.
-
-The breakdown of which string is displayed when is outlined in the table below.
-
-<table>
-    <tr>
-        <th>Range</th>
-        <th>Key</th>
-        <th>Sample Output</th>
-    </tr>
-    <tr>
-       <td>0 to 45 seconds</td>
-       <td>s</td>
-        <td>seconds ago</td>
-    </tr>
-    <tr>
-        <td>45 to 90 seconds</td>
-       <td>m</td>
-        <td>a minute ago</td>
-    </tr>
-    <tr>
-        <td>90 seconds to 45 minutes</td>
-       <td>mm</td>
-        <td>2 minutes ago ... 45 minutes ago</td>
-    </tr>
-    <tr>
-        <td>45 to 90 minutes</td>
-       <td>h</td>
-        <td>an hour ago</td>
-    </tr>
-    <tr>
-        <td>90 minutes to 22 hours </td>
-       <td>hh</td>
-        <td>2 hours ago ... 22 hours ago</td>
-    </tr>
-    <tr>
-        <td>22 to 36 hours</td>
-       <td>d</td>
-        <td>a day ago</td>
-    </tr>
-    <tr>
-        <td>36 hours to 25 days</td>
-       <td>dd</td>
-        <td>2 days ago ... 25 days ago</td>
-    </tr>
-    <tr>
-        <td>25 to 45 days</td>
-       <td>M</td>
-        <td>a month ago</td>
-    </tr>
-    <tr>
-        <td>45 to 345 days</td>
-       <td>MM</td>
-        <td>2 months ago ... 11 months ago</td>
-    </tr>
-    <tr>
-        <td>345 to 547 days (1.5 years)</td>
-       <td>y</td>
-        <td>a year ago</td>
-    </tr>
-    <tr>
-        <td>548 days+</td>
-       <td>yy</td>
-        <td>2 years ago ... 20 years ago</td>
-    </tr>
-</table>
-
-
-_date.fromNow()
----------------
-
-    _date.fromNow(withoutSuffix:boolean, asMilliseconds:boolean)
-
-Retuns the time from now.
-A shortcut for `_date.from(_date(), withoutSuffix:boolean, asMilliseconds:boolean)`.
-
-    
-_date.isLeapYear()
-------------------
-
-Returns `true` if the year is a leap year, `false` if it is not
-
-Examples :
-
-    _date([2000]).isLeapYear() // true
-    _date([2001]).isLeapYear() // false
-    _date([2100]).isLeapYear() // false
-
-Localization and Customization
-==============================
-
-_date.lang()
-------------
-
-Add or switch a language.
-
-To add a language, pass in the language key and the language constants. _date will cache the language based on the key for reuse.
-
-    _date.lang('pt', {
-        months : ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
-        monthsShort : ["Jan", "Feb", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"],
-        weekdays : ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"],
-        weekdaysShort : ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"],
-        relativeTime : {
-            future: "em %s",
-            past: "%s atrás",
-            s: "segundos",
-            m: "um minuto",
-            mm: "%d minutos",
-            h: "uma hora",
-            hh: "%d horas",
-            d: "um dia",
-            dd: "%d dias",
-            M: "um mês",
-            MM: "%d meses",
-            y: "um ano",
-            yy: "%d anos"
-        },
-        ordinal : function (number) {
-            return 'º';
-        },
-    }
-
-Once a language has been set, all `_date.format` and `_date.from` calls will use that language. To change to another language,
-call `_date.lang('otherlang', { months : [] ... })`.
-
-Once a language has been cached, you can simply call the key to retrieve it from the cache. This allows for easily switching
-between multiple languages.
-
-    _date.lang('pt');
-    _date(1316116057189).fromNow() // uma hora atrás
-    _date.lang('en');
-    _date(1316116057189).fromNow() // an hour ago
-
-There are languages in the `./underderscore.date.lang/` folder. You can `require()` them or add them to your page in the browser.
-
-### Node
-
-    var _date = require('underscore.date.js')
-    var testLang = require('underscore.date.lang/test.js');
-    _date.lang(testLang.abbr, testLang.lang);
-
-### Browser
-
-    <script src="underderscore.date.lang/leet.js"></script>
-
-NOTE: The language should be included after underscore.date, and will automatically switch to that language.
-To switch back to english, just use `_date.lang('en')` as that language is provided by default.
-
-Ad Hoc customization
---------------------
-
-If you want to customize the wording of `_date.format()` and `_date.from()`, but don't want to create an entire language object,
-the strings are exposed through the _date object. You can modify these however you see fit. However, calls to `_date.lang` will overwrite them.
-
-Examples :
-
-    _date.relativeTime.future = "%s from now";
-    _date.relativeTime.past = "%s in the past";
-
-_date.relativeTime
-------------------
-
-    _date.relativeTime = {
-        future: "in %s",
-        past: "%s ago",
-        s: "seconds",
-        m: "a minute",
-        mm: "%d minutes",
-        h: "an hour",
-        hh: "%d hours",
-        d: "a day",
-        dd: "%d days",
-        M: "a month",
-        MM: "%d months",
-        y: "a year",
-        yy: "%d years"
-    };
-
-The strings used in `_date.from()`.
-
-`future` and `past` are used as the suffixes/prefixes.
-
-For all these values, a single character refers to the singular, and an double character refers to the plural.
-
-_date.weekdays
---------------
-
-    _date.weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
-    
-An array of day names, starting with Sunday. 
-
-_date.weekdaysShort
--------------------
-
-    _date.weekdaysShort = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
-    
-An array of abbreviated day names, starting with Sunday. 
-
-_date.months
-------------
-
-    _date.months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
-    
-An array of the names of the months, starting with January.
-
-_date.monthsShort
------------------
-
-    _date.monthsShort = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
-    
-An array of the abbreviated names of the months, starting with January.
-
-_date.ordinal
--------------
-
-    _date.ordinal = function (number) {
-        var b = number % 10;
-        return (~~ (number % 100 / 10) === 1) ? 'th' : 
-            (b === 1) ? 'st' : 
-            (b === 2) ? 'nd' : 
-            (b === 3) ? 'rd' : 'th';
-    };
-    
-A function that returns a string to be appended to the number passed in.
-[More information on ordinal numbers](http://en.wikipedia.org/wiki/Ordinal_number_%28linguistics%29)
-
-
-
-Tests
-=====
-
-### Unit tests
-
-[Underscore.date unit tests](http://timrwood.github.com/underscore.date/test/test.html)
-
-[Underscore.date performance tests](http://jsperf.com/underscore-date)
-
-The unit tests can also be run in node by running `node test.js` on the root folder.
-
-
-### Speed tests
-[Floor vs bitwiseor vs bitwisenor vs parseint](http://jsperf.com/floor-vs-bitwise-or-vs-parseint/4)
-
-[Switch/case vs object of functions lookup](http://jsperf.com/object-of-functions-vs-switch)
+Documentation
+=============
 
-[Left zero filling](http://jsperf.com/left-zero-filling)
+Read the documentation at [momentjs.com/docs](http://momentjs.com/docs).
 
 Thanks to...
 ============
@@ -705,17 +28,17 @@ Everyone who helped with [php.js date](http://phpjs.org/functions/date:380).
 License
 =======
 
-Moment is freely distributable under the terms of the MIT license.
+Moment.js is freely distributable under the terms of the MIT license.
 
 Changelog
 =========
 
-### 0.7.0
+### 1.0.0
 
 Added convenience methods for getting and setting date parts
 Added better support for `moment.add()`
 Added better lang support in node
-Renamed library from underscore.date to moment
+Renamed library from underscore.date to Moment.js
 
 ### 0.6.1
 
index f7fc8917a36878a4fab7a4a0e0894d6fcd22fba2..4c827b907dd0f9d0519c14d4f1ff5ce211e9d927 100755 (executable)
--- a/build.js
+++ b/build.js
@@ -38,8 +38,8 @@ var JSHINT_CONFIG = {
 var LANG_MINIFY = "fr it pt".split(" ");
 var LANG_TEST = "en fr it pt".split(" ");
 var LANG_PREFIX = "var moment;if (typeof window === 'undefined') {moment = require('../moment.js');module = QUnit.module;}";
-var VERSION = '0.7.0';
-var MINIFY_COMMENT = '/* moment | version : ' + VERSION + ' | author : Tim Wood | license : MIT */\n';
+var VERSION = '1.0.0';
+var MINIFY_COMMENT = '/* Moment.js | version : ' + VERSION + ' | author : Tim Wood | license : MIT */\n';
 
 
 /*********************************************
index 4accee72794caf9c0c241fe49a2833c2eb9f763e..ef59511d8cbbf83934b3726355053e6f939f908c 100644 (file)
@@ -44,9 +44,9 @@
                 <li><a href="#/display/format">Formatted date</a></li>
                 <li><a href="#/display/from">Time from another moment</a></li>
                 <li><a href="#/display/fromNow">Time from now</a></li>
+                <li><a href="#/display/diff">Difference</a></li>
                 <li><a href="#/display/native">Native Date</a></li>
-                <li><a href="#/display/valueOf">valueOf</a></li>
-                <li><a href="#/display/diff">Diff</a></li>
+                <li><a href="#/display/valueOf">Value</a></li>
                 <li><a href="#/display/seconds">Seconds</a></li>
                 <li><a href="#/display/minutes">Minutes</a></li>
                 <li><a href="#/display/hours">Hours</a></li>
                 <li><a href="#/i18n/lang">Changing languages</a></li>
                 <li><a href="#/i18n/node">Loading languages in NodeJS</a></li>
                 <li><a href="#/i18n/browser">Loading languages in the browser</a></li>
+                <li><a href="#/i18n/add">Adding your language to Moment.js</a></li>
+            </ul>
+            <h1><a href="#/custom">Customization</a></h1>
+            <ul>
+                <li><a href="#/custom/months">Month Names</a></li>
+                <li><a href="#/custom/monthsShort">Month Abbreviations</a></li>
+                <li><a href="#/custom/weekdays">Weekday Names</a></li>
+                <li><a href="#/custom/weekdaysShort">Weekday Abbreviations</a></li>
+                <li><a href="#/custom/relativeTime">Relative Time</a></li>
+                <li><a href="#/custom/ordinal">Ordinal</a></li>
             </ul>
         </div>
         <div id="docs">
             <a name="/get-it/github"></a>
             <h2>Github</h2>
             <p>
-                <a href="http://github.com/timrwood/moment/moment.js">Development Version (0.7.0)</a> 20k Source + Comments
+                <a href="http://github.com/timrwood/moment/moment.js">Development Version (1.0.0)</a> 20k Source + Comments
             </p>
             <p>
-                <a href="http://github.com/timrwood/moment/moment.min.js">Production Version (0.7.0)</a> 2.2k Minified + Gzipped.
+                <a href="http://github.com/timrwood/moment/moment.min.js">Production Version (1.0.0)</a> 2.2k Minified + Gzipped.
             </p>
             <p>You can also clone the project with <a href="http://git-scm.com">Git</a> by running:
 <pre>$ git clone git://github.com/timrwood/moment</pre>
@@ -94,13 +104,14 @@ moment().add('hours', 1).fromNow(); // "1 hour ago"
             <h2>In the browser</h2>
             <p>
 <pre>
-&lt;script src="moment.js"&gt;&lt;/script&gt;
+&lt;script src="moment.min.js"&gt;&lt;/script&gt;
 moment().add('hours', 1).fromNow(); // "1 hour ago"
 </pre>
             </p>
             <a name="/parsing"></a>
             <h1>Parsing</h1>
-            <p>Instead of modifying the native <code>Date.prototype</code>, Moment.js creates a wrapper for the <code>Date</code> object</p>
+            <p>Instead of modifying the native <code>Date.prototype</code>, Moment.js creates a wrapper for the <code>Date</code> object.</p>
+            <p>Note: The Moment.js prototype is exposed through <code>moment.fn</code>. If you want to add your own functions, that is where you would put them.</p>
             <p>To get this wrapper object, simply call <code>moment()</code> with one of the supported input types</p>
             <a name="/parsing/date"></a>
             <h2>Javascript Date Object</h2>
@@ -373,7 +384,7 @@ moment().year(1984); // set the year to 1984
             <h1>Display</h1>
             <p>Once parsing and manipulation are done, you need some way to display the moment. Moment.js offers many ways of doing that.</p>
             <a name="/display/format"></a>
-            <h1>Formatted Date</h1>
+            <h2>Formatted Date</h2>
             <p>The most robust display option is <code>moment.fn.format</code>. It takes a string of tokens and replaces them with their corresponding values from the Date object.</p>
             <p>
 <pre>
@@ -557,13 +568,32 @@ moment(date).format("ddd, hA");                       // "Sun, 3PM"
                 </tr>
             </table>
             <a name="/display/from"></a>
-            <h1>Time from another moment</h1>
+            <h2>Time from another moment</h2>
             <p>Another common way of displaying time, sometimes called timeago, is handled by <code>moment.fn.from</code>.</p>
             <p>
 <pre>
 var a = moment([2007, 0, 29]);
 var b = moment([2007, 0, 28]);
 a.from(b) // "a day ago"
+</pre>
+            </p>
+            <p>The first parameter is anything you can pass to <code>moment()</code> or a Moment.js object.</p>
+            <p>
+<pre>
+var a = moment([2007, 0, 29]);
+var b = moment([2007, 0, 28]);
+a.from(b);                     // "a day ago"
+a.from([2007, 0, 28]);         // "a day ago"
+a.from(new Date(2007, 0, 28)); // "a day ago"
+a.from("1-28-2007");           // "a day ago"
+</pre>
+            </p>
+            <p>NOTE: Because it only accepts one parameter to pass in the date info, if you need to use String + Format or String + Formats, you should create a Moment.js object first and then call <code>moment.fn.from</code></p>
+            <p>
+<pre>
+var a = moment();
+var b = moment("10-10-1900", "MM-DD-YYYY");
+a.from(b);
 </pre>
             </p>
             <p>If you pass <code>true</code> as the second parameter, you can get the value without the suffix. This is useful wherever you need to have a human readable length of time.</p>
@@ -571,7 +601,7 @@ a.from(b) // "a day ago"
 <pre>
 var start = moment([2007, 0, 5]);
 var end = moment([2007, 0, 10]);
-start.from(end); // "in 5 days"
+start.from(end);       // "in 5 days"
 start.from(end, true); // "5 days"
 </pre>
             </p>
@@ -640,7 +670,7 @@ start.from(end, true); // "5 days"
                 </tr>
             </table>
             <a name="/display/fromNow"></a>
-            <h1>Time from now</h1>
+            <h2>Time from now</h2>
             <p>This is just a map to <code>moment.fn.from(new Date())</code></p>
             <p>
 <pre>
@@ -650,10 +680,250 @@ moment([2007, 0, 29]).fromNow(); // 4 years ago
             <p>Like <code>moment.fn.from</code>, if you pass <code>true</code> as the second parameter, you can get the value without the suffix.</p>
             <p>
 <pre>
-moment([2007, 0, 29]).fromNow(); // 4 years ago
+moment([2007, 0, 29]).fromNow();     // 4 years ago
 moment([2007, 0, 29]).fromNow(true); // 4 years
 </pre>
             </p>
+            <a name="/display/diff"></a>
+            <h2>Difference</h2>
+            <p>To get the difference in milliseconds, use <code>moment.fn.diff</code> like you would use <code>moment.fn.from</code>.</p>
+            <p>
+<pre>
+var a = moment([2007, 0, 29]);
+var b = moment([2007, 0, 28]);
+a.diff(b) // 86400000
+</pre>
+            </p>
+            <a name="/display/native"></a>
+            <h2>Native Date</h2>
+            <p>To get the native Date object that Moment.js wraps, use <code>moment.fn.native</code>.</p>
+            <p>
+<pre>
+var a = moment([2007, 0, 29]);
+var b = moment([2007, 0, 28]);
+a.diff(b) // 86400000
+</pre>
+            </p>
+            <a name="/display/valueOf"></a>
+            <h2>Value</h2>
+            <p><code>moment.fn.valueOf</code> simply outputs the unix timestamp.</p>
+            <p>
+<pre>
+moment(1318874398806).valueOf(); // 1318874398806
+</pre>
+            </p>
+            <a name="/display/seconds"></a>
+            <h2>Seconds</h2>
+            <p>These are the getters mentioned in the <a href="#/manipulation/seconds">Manipulation</a> section above.</p>
+            <p>These map to the corresponding function on the native <code>Date</code> object.</p>
+            <p>
+<pre>
+moment().seconds() === new Date().getSeconds();
+</pre>
+            </p>
+            <a name="/display/minutes"></a>
+            <h2>Minutes</h2>
+            <p>
+<pre>
+moment().minutes(); // get the minutes
+</pre>
+            </p>
+            <a name="/display/hours"></a>
+            <h2>Hours</h2>
+            <p>
+<pre>
+moment().hours(); // get the hours
+</pre>
+            </p>
+            <a name="/display/day"></a>
+            <h2>Day</h2>
+            <p>
+<pre>
+moment().day(); // get the day 
+</pre>
+            </p>
+            <a name="/display/month"></a>
+            <h2>Month</h2>
+            <p>
+<pre>
+moment().month(); // get the month
+</pre>
+            </p>
+            <a name="/display/year"></a>
+            <h2>Year</h2>
+            <p>
+<pre>
+moment().year(); // get the year
+</pre>
+            </p>
+            <a name="/display/leapyear"></a>
+            <h2>Leap Year</h2>
+            <p><code>moment.fn.isLeapYear</code> returns true if that year is a leap year, and false if it is not.</p>
+            <p>
+<pre>
+moment([2000]).isLeapYear() // true
+moment([2001]).isLeapYear() // false
+moment([2100]).isLeapYear() // false
+</pre>
+            </p>
+            <a name="/i18n"></a>
+            <h1>I18N</h1>
+            <p>Moment.js has pretty robust support for internationalization. You can load multiple languages onto the same instance and easily switch between them.</p>
+            <a name="/i18n/lang"></a>
+            <h2>Changing languages</h2>
+            <p>By default, Moment.js comes with English language strings. If you need other languages, you can load them into Moment.js for later use.</p>
+            <p>To load a language, pass the key and the string values to <code>moment.lang</code>.</p>
+            <p>Note: More details on each of the parts of the language bundle can be found in the <a href="#/custom">customization</a> section.</p>
+            <p>
+<pre>
+moment.lang('fr', {
+    months : "Janvier_Février_Mars_Avril_Mai_Juin_Juillet_Aout_Septembre_Octobre_Novembre_Décembre".split("_"),
+    monthsShort : "Jan_Fev_Mar_Avr_Mai_Juin_Juil_Aou_Sep_Oct_Nov_Dec".split("_"),
+    weekdays : "Dimanche_Lundi_Mardi_Mercredi_Jeudi_Vendredi_Samedi".split("_"),
+    weekdaysShort : "Dim_Lun_Mar_Mer_Jeu_Ven_Sam".split("_"),
+    relativeTime : {
+        future : "in %s",
+        past : "il y a %s",
+        s : "secondes",
+        m : "une minute",
+        mm : "%d minutes",
+        h : "une heure",
+        hh : "%d heures",
+        d : "un jour",
+        dd : "%d jours",
+        M : "un mois",
+        MM : "%d mois",
+        y : "une année",
+        yy : "%d années"
+    },
+    ordinal : function (number) {
+        return (~~ (number % 100 / 10) === 1) ? 'er' : 'ème';
+    }
+});
+</pre>
+            </p>
+            <p>Once you load a language, it becomes the active language. To change active languages, simply call <code>moment.lang</code> with the key of a loaded language.</p>
+            <p>
+<pre>
+moment.lang('fr');
+moment(1316116057189).fromNow() // il y a une heure
+moment.lang('en');
+moment(1316116057189).fromNow() // an hour ago
+</pre>
+            </p>
+            <a name="/i18n/node"></a>
+            <h2>Loading languages in NodeJS</h2>
+            <p>Loading languages in NodeJS is super easy. If there is a language file in <code>moment/lang/</code> named after that key, the first call to <code>moment.lang</code> will load it.</p>
+            <p>
+<pre>
+var moment = require('moment');
+moment.lang('fr');
+moment(1316116057189).fromNow(); // il y a une heure
+</pre>
+            </p>
+            <p>Right now, there is only support for English, French, Italian, and Portuguese. If you want your language supported, create a pull request or send me an email with the <a href="#/i18n/add">required files</a>.</p>
+            <a name="/i18n/browser"></a>
+            <h2>Loading languages in the browser</h2>
+            <p>Loading languages in the browser just requires you to include the language files.</p>
+            <p>
+<pre>
+&lt;script src="moment.min.js"&gt;&lt;/script&gt;
+&lt;script src="lang/fr.js"&gt;&lt;/script&gt;
+&lt;script src="lang/pt.js"&gt;&lt;/script&gt;
+</pre>
+            </p>
+            <p>There are minified versions of each of these languages. There is also a minified version of all of the languages bundled together.</p>
+            <p>
+<pre>
+&lt;script src="moment.min.js"&gt;&lt;/script&gt;
+&lt;script src="lang/all.min.js"&gt;&lt;/script&gt;
+</pre>
+            </p>
+            <p>Ideally, you would bundle all the files you need into one file to minimize http requests.</p>
+            <p>
+<pre>
+&lt;script src="moment-fr-it.min.js"&gt;&lt;/script&gt;
+</pre>
+            </p>
+            <a name="/i18n/add"></a>
+            <h2>Adding your language to Moment.js</h2>
+            <p>To add your language to Moment.js, submit a pull request with both a language file and a test file. You can find examples in <code>moment/lang/fr.js</code> and <code>moment/test/lang/fr.js</code></p>
+            <p>To run the tests, do <code>node build</code>.</p>
+            <p>If there are no errors building, then do <code>node test</code> or open <code>moment/test/index.html</code>.</p>
+            <p>If all the tests pass, submit that pull request, and thank you for contributing!</p>
+            <a name="/custom"></a>
+            <h1>Customization</h1>
+            <p>If you don't need i18n support, you can manually override the customization values. However, any calls to <code>moment.lang</code> will override them. It is probably safer to create a language for your specific customizations than to override these values manually.</p>
+            <a name="/custom/months"></a>
+            <h2>Month Names</h2>
+            <p><code>moment.months</code> should be an array of the month names.</p>
+            <p>
+<pre>
+moment.months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
+</pre>
+            </p>
+            <a name="/custom/monthsShort"></a>
+            <h2>Month Abbreviations</h2>
+            <p><code>moment.monthsShort</code> should be an array of the month abbreviations.</p>
+            <p>
+<pre>
+moment.monthsShort = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
+</pre>
+            </p>
+            <a name="/custom/weekdays"></a>
+            <h2>Weekday Names</h2>
+            <p><code>moment.weekdays</code> should be an array of the weekdays names.</p>
+            <p>
+<pre>
+moment.weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
+</pre>
+            </p>
+            <a name="/custom/weekdaysShort"></a>
+            <h2>Weekday Abbreviations</h2>
+            <p><code>moment.weekdaysShort</code> should be an array of the weekdays abbreviations.</p>
+            <p>
+<pre>
+moment.weekdaysShort = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
+</pre>
+            </p>
+            <a name="/custom/relativeTime"></a>
+            <h2>Relative Time</h2>
+            <p><code>moment.relativeTime</code> should be an object of the replacement strings for <code>moment.fn.from</code>.</p>
+            <p>
+<pre>
+moment.relativeTime = {
+    future: "in %s",
+    past: "%s ago",
+    s: "seconds",
+    m: "a minute",
+    mm: "%d minutes",
+    h: "an hour",
+    hh: "%d hours",
+    d: "a day",
+    dd: "%d days",
+    M: "a month",
+    MM: "%d months",
+    y: "a year",
+    yy: "%d years"
+};
+</pre>
+            </p>
+            <p><code>future</code> refers to the prefix/suffix for future dates, and <code>past</code> refers to the prefix/suffix for past dates. For all others, a single character refers to the singular, and an double character refers to the plural.</p>
+            <a name="/custom/ordinal"></a>
+            <h2>Ordinal</h2>
+            <p><code>moment.ordinal</code> should be a function that returns the ordinal for a given number.</p>
+            <p>
+<pre>
+moment.ordinal = function (number) {
+    var b = number % 10;
+    return (~~ (number % 100 / 10) === 1) ? 'th' : 
+        (b === 1) ? 'st' : 
+        (b === 2) ? 'nd' : 
+        (b === 3) ? 'rd' : 'th';
+};
+</pre>
+            </p>
+            <p>For more information on ordinal numbers, see <a href="http://en.wikipedia.org/wiki/Ordinal_number_%28linguistics%29">wikipedia</a></p>
         </div>
     </body>
 </html>
index b214fdd6f9c019203dbf0cbf1bb3cb36bc4eca2c..b72c13f9765c748ed3b5ba82f09a27c7ff15b2ae 100644 (file)
--- a/moment.js
+++ b/moment.js
@@ -1,9 +1,9 @@
-// Underscore.date
+// Moment.js
 //
 // (c) 2011 Tim Wood
-// Underscore.date is freely distributable under the terms of the MIT license.
+// Moment.js is freely distributable under the terms of the MIT license.
 //
-// Version 0.6.1
+// Version 1.0.0
 
 (function (Date, undefined) {
 
index fa7dfcedea7f3c1ca73feefb7ff996db6dd7211e..03483503d9f1e1829b129de60730713d7a4d3876 100755 (executable)
@@ -1,2 +1,2 @@
-/* moment | version : 0.7.0 | author : Tim Wood | license : MIT */
+/* Moment.js | version : 1.0.0 | author : Tim Wood | license : MIT */
 (function(a,b){function j(a,b){var c=a+"";while(c.length<b)c="0"+c;return c}function k(b,c,d,e){var f=typeof c=="string",g=f?{}:c,h,i,j;return f&&e&&(g[c]=e),h=(g.ms||g.milliseconds||0)+(g.s||g.seconds||0)*1e3+(g.m||g.minutes||0)*6e4+(g.h||g.hours||0)*36e5+(g.d||g.days||0)*864e5+(g.w||g.weeks||0)*6048e5,i=(g.M||g.months||0)+(g.y||g.years||0)*12,h&&b.setMilliseconds(b.getMilliseconds()+h*d),i&&(j=b.getDate(),b.setDate(1),b.setMonth(b.getMonth()+i*d),b.setDate(Math.min((new a(b.getFullYear(),b.getMonth()+1,0)).getDate(),j))),b}function l(a){return Object.prototype.toString.call(a)==="[object Array]"}function m(b){return new a(b[0],b[1]||0,b[2]||1,b[3]||0,b[4]||0,b[5]||0,b[6]||0)}function n(b,d){function p(d){var m,q;switch(d){case"M":return e+1;case"Mo":return e+1+c.ordinal(e+1);case"MM":return j(e+1,2);case"MMM":return c.monthsShort[e];case"MMMM":return c.months[e];case"D":return f;case"Do":return f+c.ordinal(f);case"DD":return j(f,2);case"DDD":return m=new a(g,e,f),q=new a(g,0,1),~~((m-q)/864e5+1.5);case"DDDo":return m=p("DDD"),m+c.ordinal(m);case"DDDD":return j(p("DDD"),3);case"d":return h;case"do":return h+c.ordinal(h);case"ddd":return c.weekdaysShort[h];case"dddd":return c.weekdays[h];case"w":return m=new a(g,e,f-h+5),q=new a(m.getFullYear(),0,4),~~((m-q)/864e5/7+1.5);case"wo":return m=p("w"),m+c.ordinal(m);case"ww":return j(p("w"),2);case"YY":return(g+"").slice(-2);case"YYYY":return g;case"a":return i>11?"pm":"am";case"A":return i>11?"PM":"AM";case"H":return i;case"HH":return j(i,2);case"h":return i%12||12;case"hh":return j(i%12||12,2);case"m":return k;case"mm":return j(k,2);case"s":return l;case"ss":return j(l,2);case"zz":case"z":return(b.toString().match(o)||[""])[0].replace(n,"");default:return d.replace("\\","")}}var e=b.getMonth(),f=b.getDate(),g=b.getFullYear(),h=b.getDay(),i=b.getHours(),k=b.getMinutes(),l=b.getSeconds(),m=/(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?)/g,n=/[^A-Z]/g,o=/\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g;return d.replace(m,p)}function o(a,b){function i(a,b){switch(a){case"M":case"MM":c[1]=~~b-1;break;case"D":case"DD":case"DDD":case"DDDD":c[2]=~~b;break;case"YY":b=~~b,c[0]=b+(b>70?1900:2e3);break;case"YYYY":c[0]=~~b;break;case"a":case"A":h=b.toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":c[3]=~~b;break;case"m":case"mm":c[4]=~~b;break;case"s":case"ss":c[5]=~~b}}var c=[0],d=/[0-9a-zA-Z]+/g,e=a.match(d),f=b.match(d),g,h;for(g=0;g<f.length;g++)i(f[g],e[g]);return h&&c[3]<12&&(c[3]+=12),m(c)}function p(a,b){var c=Math.min(a.length,b.length),d=Math.abs(a.length-b.length),e=0,f;for(f=0;f<c;f++)~~a[f]!==~~b[f]&&e++;return e+d}function q(a,b){var c,d=/[0-9a-zA-Z]+/g,e=a.match(d),f=[],g=99,h,i,j;for(h=0;h<b.length;h++)i=o(a,b[h]),j=p(e,n(i,b[h]).match(d)),j<g&&(g=j,c=i);return c}function r(a){this._d=a}function s(a,b){return c.relativeTime[a].replace(/%d/i,b||1)}function t(a){var b=Math.abs(a)/1e3,c=b/60,e=c/60,f=e/24,g=f/365;return b<45&&s("s",d(b))||d(c)===1&&s("m")||c<45&&s("mm",d(c))||d(e)===1&&s("h")||e<22&&s("hh",d(e))||d(f)===1&&s("d")||f<25&&s("dd",d(f))||f<45&&s("M")||f<345&&s("MM",d(f/30))||d(g)===1&&s("y")||s("yy",d(g))}function u(a,b){c.fn[a]=function(a){return a?(this._d["set"+b](a),this):this._d["get"+b]()}}var c,d=Math.round,e={},f=typeof window=="undefined"&&typeof module!="undefined",g="months|monthsShort|weekdays|weekdaysShort|relativeTime|ordinal".split("|"),h,i="Month|Date|Hours|Minutes|Seconds".split("|");c=function(c,d){var e;return c&&c._d instanceof a?e=c._d:d?l(d)?e=q(c,d):e=o(c,d):e=c===b?new a:c instanceof a?c:l(c)?m(c):new a(c),new r(e)},c.lang=function(a,b){var d,h,i;b&&(e[a]=b);if(e[a])for(d=0;d<g.length;d++)h=g[d],c[h]=e[a][h]||c[h];else f&&(i=require("./lang/"+a),console.log(i),c.lang(a,i));console.log(e)},c.lang("en",{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),relativeTime:{future:"in %s",past:"%s ago",s:"seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(a){var b=a%10;return~~(a%100/10)===1?"th":b===1?"st":b===2?"nd":b===3?"rd":"th"}}),c.fn=r.prototype={valueOf:function(){return+this._d},"native":function(){return this._d},format:function(a){return n(this._d,a)},add:function(a,b){return this._d=k(this._d,a,1,b),this},subtract:function(a,b){return this._d=k(this._d,a,-1,b),this},diff:function(a,b){return this._d-c(a,b)._d},from:function(a,b){var d=this.diff(a),e=d<0?c.relativeTime.past:c.relativeTime.future,f=t(d);return b?f:e.replace(/%s/i,f)},fromNow:function(a){return this.from(c(),a)},isLeapYear:function(){var a=this._d.getFullYear();return a%4===0&&a%100!==0||a%400===0}};for(h=0;h<i.length;h++)u(i[h].toLowerCase(),i[h]);u("year","FullYear"),c.fn.day=function(){return this._d.getDay()},f?module.exports=c:this.moment=c})(Date)
\ No newline at end of file