]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Updating docs for #60
authorTim Wood <washwithcare@gmail.com>
Mon, 14 Nov 2011 17:40:06 +0000 (09:40 -0800)
committerTim Wood <washwithcare@gmail.com>
Mon, 14 Nov 2011 17:40:06 +0000 (09:40 -0800)
site/docs/index.html
site/index.html
site/test/index.html
sitesrc/docs.jade

index 6f18fd7b9088a65615135d76797cf900cdf7e3d2..4a31d447e952bb427ad9b072b345a9a56a8fa65b 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html><html><head><meta charset="utf-8"><link href="http://fonts.googleapis.com/css?family=Oswald" rel="stylesheet"><link rel="stylesheet" href="../css/style.css?_=111114_092214"><title>Moment.js Documentation</title></head><body><div id="navwrap"><div id="nav"><h1>Moment.js</h1><ul><li><a href="/" class="btn clean-gray">Home</a></li><li><a href="/docs/" class="btn clean-gray">Documentation</a></li><li><a href="/test/" class="btn clean-gray">Unit Tests</a></li><li><a href="https://github.com/timrwood/moment" class="btn clean-gray">Github</a></li></ul></div></div><div id="content"><div id="docnav"><h2><a href="#/get-it"><span>Get it</span></a></h2><ul><li><a href="#/get-it/github">Github</a></li><li><a href="#/get-it/npm">npm</a></li></ul><h2><a href="#/use-it"><span>Use it</span></a></h2><ul><li><a href="#/use-it/node">In NodeJS</a></li><li><a href="#/use-it/browser">In the browser</a></li></ul><h2><a href="#/parsing"><span>Parsing</span></a></h2><ul><li><a href="#/parsing/date">Javascript Date Object</a></li><li><a href="#/parsing/unix">Unix Timestamp</a></li><li><a href="#/parsing/string">String</a></li><li><a href="#/parsing/string+format">String + Format</a></li><li><a href="#/parsing/string+formats">String + Formats</a></li><li><a href="#/parsing/now">Now</a></li><li><a href="#/parsing/array">Javascript Array</a></li></ul><h2><a href="#/manipulation"><span>Manipulation</span></a></h2><ul><li><a href="#/manipulation/add">Add</a></li><li><a href="#/manipulation/subtract">Subtract</a></li><li><a href="#/manipulation/seconds">Seconds</a></li><li><a href="#/manipulation/minutes">Minutes</a></li><li><a href="#/manipulation/hours">Hours</a></li><li><a href="#/manipulation/date">Date</a></li><li><a href="#/manipulation/month">Month</a></li><li><a href="#/manipulation/year">Year</a></li></ul><h2><a href="#/display"><span>Display</span></a></h2><ul><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">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="#/display/date">Date</a></li><li><a href="#/display/day">Day</a></li><li><a href="#/display/month">Month</a></li><li><a href="#/display/year">Year</a></li><li><a href="#/display/leapyear">Leap Year</a></li></ul><h2><a href="#/i18n"><span>I18N</span></a></h2><ul><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><h2><a href="#/custom"><span>I18N</span></a></h2><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/longDateFormats">Long Date Formats</a></li><li><a href="#/custom/relativeTime">Relative Time</a></li><li><a href="#/custom/ordinal">Ordinal</a></li></ul></div><div id="docs"><h1>Moment.js Documentation</h1><p>A lightweight javascript date library for parsing, manipulating, and formatting dates.</p><a name="/get-it"></a><h2><span>Where to get it</span></h2><a name="/get-it/github"></a><h3><span>Github</span></h3><a href="https://raw.github.com/timrwood/moment/1.1.1/moment.min.js" class="btn cupid-green"><strong>Production </strong><span class="version">Version 1.1.1</span><span class="filesize">2.5kb minified &amp; gzipped</span></a><a href="https://raw.github.com/timrwood/moment/1.1.1/moment.js" class="btn minimal"><strong>Development </strong><span class="version">Version 1.1.1</span><span class="filesize">17.9kb full source + comments</span></a><p>You can also clone the project with Git by running:</p><pre>git clone git://github.com/timrwood/moment</pre><a name="/get-it/npm"></a><h3><span>npm</span></h3><pre>npm install moment</pre><a name="/use-it"></a><h2><span>Where to use it</span></h2><p>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.</p><a name="/use-it/node"></a><h3><span>In NodeJS</span></h3><pre>var moment = require('moment');
+<!DOCTYPE html><html><head><meta charset="utf-8"><link href="http://fonts.googleapis.com/css?family=Oswald" rel="stylesheet"><link rel="stylesheet" href="../css/style.css?_=111114_093838"><title>Moment.js Documentation</title></head><body><div id="navwrap"><div id="nav"><h1>Moment.js</h1><ul><li><a href="/" class="btn clean-gray">Home</a></li><li><a href="/docs/" class="btn clean-gray">Documentation</a></li><li><a href="/test/" class="btn clean-gray">Unit Tests</a></li><li><a href="https://github.com/timrwood/moment" class="btn clean-gray">Github</a></li></ul></div></div><div id="content"><div id="docnav"><h2><a href="#/get-it"><span>Get it</span></a></h2><ul><li><a href="#/get-it/github">Github</a></li><li><a href="#/get-it/npm">npm</a></li></ul><h2><a href="#/use-it"><span>Use it</span></a></h2><ul><li><a href="#/use-it/node">In NodeJS</a></li><li><a href="#/use-it/browser">In the browser</a></li></ul><h2><a href="#/parsing"><span>Parsing</span></a></h2><ul><li><a href="#/parsing/date">Javascript Date Object</a></li><li><a href="#/parsing/unix">Unix Timestamp</a></li><li><a href="#/parsing/string">String</a></li><li><a href="#/parsing/string+format">String + Format</a></li><li><a href="#/parsing/string+formats">String + Formats</a></li><li><a href="#/parsing/now">Now</a></li><li><a href="#/parsing/array">Javascript Array</a></li></ul><h2><a href="#/manipulation"><span>Manipulation</span></a></h2><ul><li><a href="#/manipulation/add">Add</a></li><li><a href="#/manipulation/subtract">Subtract</a></li><li><a href="#/manipulation/seconds">Seconds</a></li><li><a href="#/manipulation/minutes">Minutes</a></li><li><a href="#/manipulation/hours">Hours</a></li><li><a href="#/manipulation/date">Date</a></li><li><a href="#/manipulation/month">Month</a></li><li><a href="#/manipulation/year">Year</a></li></ul><h2><a href="#/display"><span>Display</span></a></h2><ul><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">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="#/display/date">Date</a></li><li><a href="#/display/day">Day</a></li><li><a href="#/display/month">Month</a></li><li><a href="#/display/year">Year</a></li><li><a href="#/display/leapyear">Leap Year</a></li></ul><h2><a href="#/i18n"><span>I18N</span></a></h2><ul><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><h2><a href="#/custom"><span>I18N</span></a></h2><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/longDateFormats">Long Date Formats</a></li><li><a href="#/custom/relativeTime">Relative Time</a></li><li><a href="#/custom/ordinal">Ordinal</a></li></ul></div><div id="docs"><h1>Moment.js Documentation</h1><p>A lightweight javascript date library for parsing, manipulating, and formatting dates.</p><a name="/get-it"></a><h2><span>Where to get it</span></h2><a name="/get-it/github"></a><h3><span>Github</span></h3><a href="https://raw.github.com/timrwood/moment/1.1.1/moment.min.js" class="btn cupid-green"><strong>Production </strong><span class="version">Version 1.1.1</span><span class="filesize">2.5kb minified &amp; gzipped</span></a><a href="https://raw.github.com/timrwood/moment/1.1.1/moment.js" class="btn minimal"><strong>Development </strong><span class="version">Version 1.1.1</span><span class="filesize">17.9kb full source + comments</span></a><p>You can also clone the project with Git by running:</p><pre>git clone git://github.com/timrwood/moment</pre><a name="/get-it/npm"></a><h3><span>npm</span></h3><pre>npm install moment</pre><a name="/use-it"></a><h2><span>Where to use it</span></h2><p>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.</p><a name="/use-it/node"></a><h3><span>In NodeJS</span></h3><pre>var moment = require('moment');
 moment().add('hours', 1).fromNow(); // &quot;1 hour ago&quot;
 </pre><a name="/use-it/browser"></a><h3><span>In the browser</span></h3><pre>&lt;script src="moment.min.js">&lt;/script>
 moment().add('hours', 1).fromNow(); // &quot;1 hour ago&quot;
@@ -154,8 +154,8 @@ moment(1316116057189).fromNow(); // il y a une heure
     LLL: &quot;MMMM D YYYY h:mm A&quot;,
     LLLL: &quot;dddd, MMMM D YYYY h:mm A&quot;
 };
-</pre><a name="/custom/relativeTime"></a><h3><span>Relative Time</span></h3><p><code>moment.relativeTime</code>should be an object of the replacement strings for 
-<code>moment.fn.from</code>. The functions should return the correct string for a given number.
+</pre><a name="/custom/relativeTime"></a><h3><span>Relative Time</span></h3><p><code>moment.relativeTime</code> should be an object of the replacement strings for 
+<code>moment.fn.from</code>.
 </p><pre>moment.relativeTime = {
     future: &quot;in %s&quot;,
     past: &quot;%s ago&quot;,
@@ -171,8 +171,17 @@ moment(1316116057189).fromNow(); // il y a une heure
     y: &quot;a year&quot;,
     yy: &quot;%d years&quot;
 };
-</pre><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.
+</pre><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><p>If a language requires additional processing for a token, It can set the token as a function with the following signature. The function should return a string.
+</p><pre>function(number, withoutSuffix, key) {
+    return string;
+}
+</pre><p>The <code>key</code> variable refers to the replacement key in the 
+<code>relativeTime </code> object. (eg. 's', 'm', 'mm', 'h', etc.)
+</p><p>The <code>number</code> variable refers to the number of units for that key. For 'm', the number is the number of minutes, etc.
+</p><p>The <code>withoutSuffix</code> variable will be true if the token will be displayed without a suffix, and false if it will be displayed with a suffix. 
+(The reason for the inverted logic is because the default behavior is to display with the suffix.)
 </p><a name="/custom/ordinal"></a><h3><span>Ordinal</span></h3><p><code>moment.ordinal</code>should be a function that returns the ordinal for a given number.
 </p><pre>moment.ordinal = function (number) {
     var b = number % 10;
@@ -181,7 +190,7 @@ moment(1316116057189).fromNow(); // il y a une heure
         (b === 2) ? 'nd' : 
         (b === 3) ? 'rd' : 'th';
 };
-</pre><p>For more information on ordinal numbers, see <a href="http://en.wikipedia.org/wiki/Ordinal_number_%28linguistics%29">wikipedia</a></p><div class="footer"></div></div></div><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script><script src="../js/docs.min.js?_=111114_092214"></script><script>window._gaq = [['_setAccount','UA-10641787-5'],['_trackPageview'],['_trackPageLoadTime']];
+</pre><p>For more information on ordinal numbers, see <a href="http://en.wikipedia.org/wiki/Ordinal_number_%28linguistics%29">wikipedia</a></p><div class="footer"></div></div></div><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script><script src="../js/docs.min.js?_=111114_093838"></script><script>window._gaq = [['_setAccount','UA-10641787-5'],['_trackPageview'],['_trackPageLoadTime']];
 (function(d, c) {
   var ga = d.createElement(c); ga.async = true;
   ga.src = "http://www.google-analytics.com/ga.js";
index a57b7c971ee2e6b8d7d3737e7a811f1e5a8738c4..2ec7507008ac47291bdc426884770dc9c75b1a5c 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html><html><head><meta charset="utf-8"><link href="http://fonts.googleapis.com/css?family=Oswald" rel="stylesheet"><link rel="stylesheet" href="css/style.css?_=111114_092214"><title>Moment.js - A lightweight javascript date library</title></head><body><div id="navwrap"><div id="nav"><h1>Moment.js</h1><ul><li><a href="/" class="btn clean-gray">Home</a></li><li><a href="/docs/" class="btn clean-gray">Documentation</a></li><li><a href="/test/" class="btn clean-gray">Unit Tests</a></li><li><a href="https://github.com/timrwood/moment" class="btn clean-gray">Github</a></li></ul></div></div><div id="content"><div id="home"><h2>Moment.js</h2><h3>A lightweight javascript date library for parsing, manipulating, and formatting dates.</h3><div class="col1"><h4><span>Get it</span></h4><pre>npm install moment</pre><a href="https://raw.github.com/timrwood/moment/1.1.1/moment.min.js" class="btn cupid-green"><strong>Production </strong><span class="version">Version 1.1.1</span><span class="filesize">2.5kb minified &amp; gzipped</span></a><a href="https://raw.github.com/timrwood/moment/1.1.1/moment.js" class="btn minimal"><strong>Development </strong><span class="version">Version 1.1.1</span><span class="filesize">17.9kb full source + comments</span></a></div><div class="col2"><h4><span>Use it</span></h4><pre class="js">var now = moment();
+<!DOCTYPE html><html><head><meta charset="utf-8"><link href="http://fonts.googleapis.com/css?family=Oswald" rel="stylesheet"><link rel="stylesheet" href="css/style.css?_=111114_093838"><title>Moment.js - A lightweight javascript date library</title></head><body><div id="navwrap"><div id="nav"><h1>Moment.js</h1><ul><li><a href="/" class="btn clean-gray">Home</a></li><li><a href="/docs/" class="btn clean-gray">Documentation</a></li><li><a href="/test/" class="btn clean-gray">Unit Tests</a></li><li><a href="https://github.com/timrwood/moment" class="btn clean-gray">Github</a></li></ul></div></div><div id="content"><div id="home"><h2>Moment.js</h2><h3>A lightweight javascript date library for parsing, manipulating, and formatting dates.</h3><div class="col1"><h4><span>Get it</span></h4><pre>npm install moment</pre><a href="https://raw.github.com/timrwood/moment/1.1.1/moment.min.js" class="btn cupid-green"><strong>Production </strong><span class="version">Version 1.1.1</span><span class="filesize">2.5kb minified &amp; gzipped</span></a><a href="https://raw.github.com/timrwood/moment/1.1.1/moment.js" class="btn minimal"><strong>Development </strong><span class="version">Version 1.1.1</span><span class="filesize">17.9kb full source + comments</span></a></div><div class="col2"><h4><span>Use it</span></h4><pre class="js">var now = moment();
 console.log(now.format('dddd, MMMM Do YYYY, h:mm:ss a'));
 </pre><h5><span id="js-format-now"></span></h5><pre class="js">var aWhileAgo = moment([2011, 10, 30]);
 console.log(aWhileAgo.fromNow());
@@ -7,7 +7,7 @@ console.log(now.format('dddd, MMMM Do YYYY'));
 </pre><h5><span id="js-add"></span></h5><pre class="js">var now = moment();
 moment.lang('fr')
 console.log(now.format('LLLL'));
-</pre><h5><span id="js-lang"></span></h5></div></div></div><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script><script src="js/home.min.js?_=111114_092214"></script><script>window._gaq = [['_setAccount','UA-10641787-5'],['_trackPageview'],['_trackPageLoadTime']];
+</pre><h5><span id="js-lang"></span></h5></div></div></div><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script><script src="js/home.min.js?_=111114_093838"></script><script>window._gaq = [['_setAccount','UA-10641787-5'],['_trackPageview'],['_trackPageLoadTime']];
 (function(d, c) {
   var ga = d.createElement(c); ga.async = true;
   ga.src = "http://www.google-analytics.com/ga.js";
index 3e03dc86a770a23713cda0daec93efa5f567a76f..66b96e01c1c29fce55bb08c1f48a91695aab01ee 100755 (executable)
@@ -1,4 +1,4 @@
-<!DOCTYPE html><html><head><meta charset="utf-8"><link href="http://fonts.googleapis.com/css?family=Oswald" rel="stylesheet"><link rel="stylesheet" href="../css/style.css?_=111114_092214"><title>Moment.js Unit Test Suite</title></head><body><div id="navwrap"><div id="nav"><h1>Moment.js</h1><ul><li><a href="/" class="btn clean-gray">Home</a></li><li><a href="/docs/" class="btn clean-gray">Documentation</a></li><li><a href="/test/" class="btn clean-gray">Unit Tests</a></li><li><a href="https://github.com/timrwood/moment" class="btn clean-gray">Github</a></li></ul></div></div><div id="content"><div id="test"><h1>Moment.js unit test suite</h1><h2 id="qunit-banner"></h2><h4 id="qunit-userAgent"></h4><ol id="qunit-tests"></ol></div></div><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script><script src="../js/moment.min.js?_=111114_092214"></script><script src="../js/lang-all.min.js?_=111114_092214"></script><script src="../js/test.min.js?_=111114_092214"></script><script>window._gaq = [['_setAccount','UA-10641787-5'],['_trackPageview'],['_trackPageLoadTime']];
+<!DOCTYPE html><html><head><meta charset="utf-8"><link href="http://fonts.googleapis.com/css?family=Oswald" rel="stylesheet"><link rel="stylesheet" href="../css/style.css?_=111114_093838"><title>Moment.js Unit Test Suite</title></head><body><div id="navwrap"><div id="nav"><h1>Moment.js</h1><ul><li><a href="/" class="btn clean-gray">Home</a></li><li><a href="/docs/" class="btn clean-gray">Documentation</a></li><li><a href="/test/" class="btn clean-gray">Unit Tests</a></li><li><a href="https://github.com/timrwood/moment" class="btn clean-gray">Github</a></li></ul></div></div><div id="content"><div id="test"><h1>Moment.js unit test suite</h1><h2 id="qunit-banner"></h2><h4 id="qunit-userAgent"></h4><ol id="qunit-tests"></ol></div></div><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script><script src="../js/moment.min.js?_=111114_093838"></script><script src="../js/lang-all.min.js?_=111114_093838"></script><script src="../js/test.min.js?_=111114_093838"></script><script>window._gaq = [['_setAccount','UA-10641787-5'],['_trackPageview'],['_trackPageLoadTime']];
 (function(d, c) {
   var ga = d.createElement(c); ga.async = true;
   ga.src = "http://www.google-analytics.com/ga.js";
index 7fb0165a4d5f2cbbcaac536040f9985c8f6de256..774ac81d9aaed44e35128b001bad3bfa47364fc9 100644 (file)
@@ -967,9 +967,9 @@ block content
         span Relative Time
       p
         code moment.relativeTime
-        | should be an object of the replacement strings for 
+        |  should be an object of the replacement strings for 
         code moment.fn.from
-        | . The functions should return the correct string for a given number.
+        | .
       pre moment.relativeTime = {\n
         |     future: "in %s",
         |     past: "%s ago",
@@ -987,9 +987,26 @@ block content
         | };
       p
         code future
-        | refers to the prefix/suffix for future dates, and 
+        |  refers to the prefix/suffix for future dates, and 
         code past
-        | 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.
+        |  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 If a language requires additional processing for a token, It can set the token as a function with the following signature. 
+        | The function should return a string.
+      pre function(number, withoutSuffix, key) {\n
+        |     return string;
+        | }
+      p The 
+        code key
+        |  variable refers to the replacement key in the 
+        code relativeTime 
+        |  object. (eg. 's', 'm', 'mm', 'h', etc.)
+      p The 
+        code number
+        |  variable refers to the number of units for that key. For 'm', the number is the number of minutes, etc.
+      p The 
+        code withoutSuffix
+        |  variable will be true if the token will be displayed without a suffix, and false if it will be displayed with a suffix. 
+        | (The reason for the inverted logic is because the default behavior is to display with the suffix.)
 
 
       a(name="/custom/ordinal")