From: Tim Wood Date: Tue, 1 Nov 2011 22:00:54 +0000 (-0700) Subject: Adding day getter to docs X-Git-Tag: 1.1.1~18^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7799dc4facb29b097675efd9990cc30296644b4;p=thirdparty%2Fmoment.git Adding day getter to docs --- diff --git a/site/docs/index.html b/site/docs/index.html index 40076a640..57286dcbc 100644 --- a/site/docs/index.html +++ b/site/docs/index.html @@ -1,4 +1,4 @@ -

Moment.js Documentation

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

Where to get it

Github

Production Version 1.1.02.5kb minified & gzippedDevelopment Version 1.1.017.7kb 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

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

Where to get it

Github

Production Version 1.1.02.5kb minified & gzippedDevelopment Version 1.1.017.7kb 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"
@@ -36,7 +36,7 @@ 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

Day

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. +

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"
@@ -84,7 +84,7 @@ a.diff(b, 'years', true) // 1.5
 

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.

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 

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().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([2000]).isLeapYear() // true
 moment([2001]).isLeapYear() // false
 
diff --git a/sitesrc/docs.jade b/sitesrc/docs.jade
index 44c777cf6..255c6fbac 100644
--- a/sitesrc/docs.jade
+++ b/sitesrc/docs.jade
@@ -86,6 +86,8 @@ block content
           a(href="#/display/hours") Hours
         li
           a(href="#/display/date") Date
+        li
+          a(href="#/display/day") Day
         li
           a(href="#/display/month") Month
         li
@@ -402,7 +404,7 @@ block content
 
       a(name="/manipulation/date")
       h3
-        span Day
+        span Date
       pre moment().date(5); // set the date to 5
 
 
@@ -764,7 +766,13 @@ block content
       a(name="/display/date")
       h3
         span Date
-      pre moment().date(); // get the date 
+      pre moment().date(); // get the date (0 - 31)
+
+
+      a(name="/display/day")
+      h3
+        span Day
+      pre moment().day(); // get the day (0 - 6)
 
 
       a(name="/display/month")