From: Tim Wood Date: Thu, 15 Dec 2011 21:30:31 +0000 (-0800) Subject: Build for #99 X-Git-Tag: 1.3.0~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d2065e4d995e42f93d244375715faa2a081937f;p=thirdparty%2Fmoment.git Build for #99 --- diff --git a/moment.min.js b/moment.min.js index 7febf62c6..deb29a96d 100755 --- a/moment.min.js +++ b/moment.min.js @@ -1,2 +1,2 @@ /* Moment.js | version : 1.2.0 | author : Tim Wood | license : MIT */ -(function(a,b){function k(a,b){var c=a+"";while(c.length11?s.pm:s.am;case"A":return i>11?s.PM:s.AM;case"H":return i;case"HH":return k(i,2);case"h":return i%12||12;case"hh":return k(i%12||12,2);case"m":return j;case"mm":return k(j,2);case"s":return l;case"ss":return k(l,2);case"zz":case"z":return(b.toString().match(q)||[""])[0].replace(p,"");case"Z":return(m>0?"+":"-")+k(~~(Math.abs(m)/60),2)+":"+k(~~(Math.abs(m)%60),2);case"ZZ":return(m>0?"+":"-")+k(~~(10*Math.abs(m)/6),4);case"L":case"LL":case"LLL":case"LLLL":return o(b,c.longDateFormat[d]);default:return d.replace("\\","")}}var e=b.getMonth(),f=b.getDate(),g=b.getFullYear(),h=b.getDay(),i=b.getHours(),j=b.getMinutes(),l=b.getSeconds(),m=b.getTimezoneOffset(),n=/(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?|ZZ?|LL?L?L?)/g,p=/[^A-Z]/g,q=/\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g,r=c.ordinal,s=c.meridiem;return d.replace(n,t)}function p(b,c){function p(a,b){var c;switch(a){case"M":case"MM":d[1]=~~b-1;break;case"D":case"DD":case"DDD":case"DDDD":d[2]=~~b;break;case"YY":b=~~b,d[0]=b+(b>70?1900:2e3);break;case"YYYY":d[0]=~~Math.abs(b);break;case"a":case"A":o=b.toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":d[3]=~~b;break;case"m":case"mm":d[4]=~~b;break;case"s":case"ss":d[5]=~~b;break;case"Z":case"ZZ":g=!0,c=b.match(j),c[1]&&(e=~~c[1]),c[2]&&(f=~~c[2]),c[0]==="-"&&(e=-e,f=-f)}}var d=[0,0,1,0,0,0,0],e=0,f=0,g=!1,h=/(\\)?(MM?|DD?D?D?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|ZZ?)/g,i=/(\\)?([0-9]+|am|pm|([\+\-]\d\d:?\d\d))/gi,j=/([\+\-]|\d\d)/gi,k=b.match(i),l=c.match(h),m,o;for(m=0;m11?s.pm:s.am;case"A":return i>11?s.PM:s.AM;case"H":return i;case"HH":return k(i,2);case"h":return i%12||12;case"hh":return k(i%12||12,2);case"m":return j;case"mm":return k(j,2);case"s":return l;case"ss":return k(l,2);case"zz":case"z":return(b.toString().match(q)||[""])[0].replace(p,"");case"Z":return(m>0?"+":"-")+k(~~(Math.abs(m)/60),2)+":"+k(~~(Math.abs(m)%60),2);case"ZZ":return(m>0?"+":"-")+k(~~(10*Math.abs(m)/6),4);case"L":case"LL":case"LLL":case"LLLL":return o(b,c.longDateFormat[d]);default:return d.replace("\\","")}}var e=b.getMonth(),f=b.getDate(),g=b.getFullYear(),h=b.getDay(),i=b.getHours(),j=b.getMinutes(),l=b.getSeconds(),m=b.getTimezoneOffset(),n=/(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?|ZZ?|LL?L?L?)/g,p=/[^A-Z]/g,q=/\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g,r=c.ordinal,s=c.meridiem;return d.replace(n,t)}function p(b,c){function p(a,b){var c;switch(a){case"M":case"MM":d[1]=~~b-1;break;case"D":case"DD":case"DDD":case"DDDD":d[2]=~~b;break;case"YY":b=~~b,d[0]=b+(b>70?1900:2e3);break;case"YYYY":d[0]=~~Math.abs(b);break;case"a":case"A":o=b.toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":d[3]=~~b;break;case"m":case"mm":d[4]=~~b;break;case"s":case"ss":d[5]=~~b;break;case"Z":case"ZZ":g=!0,c=b.match(j),c[1]&&(e=~~c[1]),c[2]&&(f=~~c[2]),c[0]==="-"&&(e=-e,f=-f)}}var d=[0,0,1,0,0,0,0],e=0,f=0,g=!1,h=/(\\)?(MM?|DD?D?D?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|ZZ?)/g,i=/(\\)?([0-9]+|am|pm|([\+\-]\d\d:?\d\d))/gi,j=/([\+\-]|\d\d)/gi,k=b.match(i),l=c.match(h),m,o;for(m=0;mMoment.js Documentation

Moment.js Documentation

A lightweight javascript date library for parsing, manipulating, and formatting dates.

Where to get it

Github

Production Version 1.2.02.8kb minified & gzippedDevelopment Version 1.2.020.1kb full source + comments

You can also clone the project with Git by running:

git clone git://github.com/timrwood/moment

npm

npm install moment

Where to use it

Moment was designed to work in both the browser and in NodeJS. All code will work in both environments. All unit tests are run in both environments.

In NodeJS

var moment = require('moment');
+Moment.js Documentation

Moment.js Documentation

A lightweight javascript date library for parsing, manipulating, and formatting dates.

Where to get it

Github

Production Version 1.2.02.8kb minified & gzippedDevelopment Version 1.2.020.2kb full source + comments

You can also clone the project with Git by running:

git clone git://github.com/timrwood/moment

npm

npm install moment

Where to use it

Moment was designed to work in both the browser and in NodeJS. All code will work in both environments. All unit tests are run in both environments.

In NodeJS

var moment = require('moment');
 moment().add('hours', 1).fromNow(); // "1 hour ago"
 

In the browser

<script src="moment.min.js"></script>
 moment().add('hours', 1).fromNow(); // "1 hour ago"
@@ -44,12 +44,12 @@ m.add('days', 1).hours(); // 5
 m.hours(); // 5
 m.add('hours', 24).hours(); // 6
 

Subtracting Time

This is exactly the same as moment.fn.add, only instead of adding time, it subtracts time. -

moment().subtract('days', 7);

Seconds

There are a number of shortcut getter and setter functions. Much like in jQuery, calling the function without paremeters causes it to function as a getter, +

moment().subtract('days', 7);

Milliseconds

There are a number of shortcut getter and setter functions. Much like in jQuery, calling the function without paremeters causes it to function as a getter, and calling with a parameter causes it to function as a setter.

These map to the corresponding function on the native Dateobject. -

moment().seconds(30) === new Date().setSeconds(30);
-moment().seconds() === new Date().getSeconds();
-

Minutes

moment().minutes(30); // set the minutes to 30

Hours

moment().hours(12); // set the hours to 12

Date

moment().date(5); // set the date to 5

Month

moment().month(5); // set the month to June

Year

moment().year(1984); // set the year to 1984

Display

Once parsing and manipulation are done, you need some way to display the moment. Moment.js offers many ways of doing that.

Formatted Date

The most robust display option is moment.fn.format. It takes a string of tokens and replaces them with their corresponding values from the Date object. +

moment().milliseconds(30) === new Date().setMilliseconds(30);
+moment().milliseconds() === new Date().getMilliseconds();
+

Seconds

moment().seconds(30); // set the seconds to 30

Minutes

moment().minutes(30); // set the minutes to 30

Hours

moment().hours(12); // set the hours to 12

Date

moment().date(5); // set the date to 5

Month

moment().month(5); // set the month to June

Year

moment().year(1984); // set the year to 1984

Display

Once parsing and manipulation are done, you need some way to display the moment. Moment.js offers many ways of doing that.

Formatted Date

The most robust display option is moment.fn.format. It takes a string of tokens and replaces them with their corresponding values from the Date object.

var date = new Date(2010, 1, 14, 15, 25, 50, 125);
 moment(date).format("dddd, MMMM Do YYYY, h:mm:ss a"); // "Sunday, February 14th 2010, 3:25:50 pm"
 moment(date).format("ddd, hA");                       // "Sun, 3PM"
@@ -97,9 +97,9 @@ a.diff(b, 'years')       // 1
 a.diff(b, 'years', true) // 1.5
 

Native Date

To get the native Date object that Moment.js wraps, use moment.fn.native.

moment([2007, 0, 29]).native(); // returns native Date object

Value

moment.fn.valueOfsimply outputs the unix timestamp. -

moment(1318874398806).valueOf(); // 1318874398806

Seconds

These are the getters mentioned in the Manipulationsection above. +

moment(1318874398806).valueOf(); // 1318874398806

Milliseconds

These are the getters mentioned in the Manipulationsection above.

These map to the corresponding function on the native Dateobject. -

moment().seconds() === new Date().getSeconds();

Minutes

moment().minutes(); // get the minutes

Hours

moment().hours(); // get the hours

Date

moment().date(); // get the date (0 - 31)

Day

moment().day(); // get the day (0 - 6)

Month

moment().month(); // get the month

Year

moment().year(); // get the year

Leap Year

moment.fn.isLeapYearreturns true if that year is a leap year, and false if it is not. +

moment().milliseconds() === new Date().getMilliseconds();

Seconds

moment().minutes(); // get the seconds

Minutes

moment().minutes(); // get the minutes

Hours

moment().hours(); // get the hours

Date

moment().date(); // get the date (0 - 31)

Day

moment().day(); // get the day (0 - 6)

Month

moment().month(); // get the month

Year

moment().year(); // get the year

Leap Year

moment.fn.isLeapYearreturns true if that year is a leap year, and false if it is not.

moment([2000]).isLeapYear() // true
 moment([2001]).isLeapYear() // false
 moment([2100]).isLeapYear() // false
@@ -220,7 +220,7 @@ moment(1316116057189).fromNow(); // il y a une heure
         (b === 2) ? 'nd' : 
         (b === 3) ? 'rd' : 'th';
 };
-

For more information on ordinal numbers, see wikipedia