]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Adding customization options for am/pm strings #67
authorTim Wood <washwithcare@gmail.com>
Tue, 15 Nov 2011 17:41:24 +0000 (09:41 -0800)
committerTim Wood <washwithcare@gmail.com>
Tue, 15 Nov 2011 17:41:24 +0000 (09:41 -0800)
lang/de.js
lang/es.js
lang/fr.js
lang/it.js
lang/nb.js
lang/nl.js
lang/pl.js
lang/pt.js
lang/sv.js
moment.js
sitesrc/docs.jade

index 27ea9c920f3793ff09c254b8b8bb66a7bec764fb..e8ab0a29be756a47dd0dec6e50f245d4792acb96 100644 (file)
                 LLL : "D. MMMM YYYY HH:mm U\\hr",
                 LLLL : "dddd, D. MMMM YYYY HH:mm U\\hr"
             },
+            meridiem : {
+                AM : 'AM',
+                am : 'am',
+                PM : 'PM',
+                pm : 'pm'
+            },
             relativeTime : {
                 future : "in %s",
                 past : "vor %s",
index 53b781c4f31e25a4bcf47a9bf2f79a8b714a58f6..f0ebc3f04eee5479a9e502c4fd9dff4bab1295c2 100644 (file)
                 LLL : "D MMMM YYYY HH:mm",
                 LLLL : "dddd D MMMM YYYY HH:mm"
             },
+            meridiem : {
+                AM : 'AM',
+                am : 'am',
+                PM : 'PM',
+                pm : 'pm'
+            },
             relativeTime : {
                 future : "en %s",
                 past : "hace %s",
index 5e3aeccdb83cc463c368ec365978c999edc8476f..ad84ed53fed056d07c500dc032dfd39a6947dd07 100644 (file)
                 LLL : "D MMMM YYYY HH:mm",
                 LLLL : "dddd D MMMM YYYY HH:mm"
             },
+            meridiem : {
+                AM : 'AM',
+                am : 'am',
+                PM : 'PM',
+                pm : 'pm'
+            },
             relativeTime : {
                 future : "dans %s",
                 past : "il y a %s",
index 68281bb004645bd911498c4016d491169e4a551c..3c83cf8cc3ba7e0046b36756fd1bda2f762f885c 100644 (file)
@@ -4,13 +4,18 @@
             monthsShort : "Gen_Feb_Mar_Apr_Mag_Giu_Lug_Ago_Set_Ott_Nov_Dic".split("_"),
             weekdays : "Domenica_Lunedi_Martedi_Mercoledi_Giovedi_Venerdi_Sabato".split("_"),
             weekdaysShort : "Dom_Lun_Mar_Mer_Gio_Ven_Sab".split("_"),
-            // copied from french, needs revision from italian speakers
             longDateFormat : { 
                 L : "DD/MM/YYYY",
                 LL : "D MMMM YYYY",
                 LLL : "D MMMM YYYY HH:mm",
                 LLLL : "dddd, D MMMM YYYY HH:mm"
             },
+            meridiem : {
+                AM : 'AM',
+                am : 'am',
+                PM : 'PM',
+                pm : 'pm'
+            },
             relativeTime : {
                 future : "in %s",
                 past : "%s fa",
index 8bd8a66eac6366ca99c3c1de9e66ccf21c794e22..c8407ccb84f1b0cf1d40e3f88964378016c5e8c3 100644 (file)
                 LLL : "D MMMM YYYY HH:mm",
                 LLLL : "dddd D MMMM YYYY HH:mm"
             },
+            meridiem : {
+                AM : 'AM',
+                am : 'am',
+                PM : 'PM',
+                pm : 'pm'
+            },
             relativeTime : {
                 future : "om %s",
                 past : "for %s siden",
index 86b72910f161204fadbba33e8f7c0af9d7209d43..9470b00b5c2089952496141c2164c2af1b2f63ef 100644 (file)
                 LLL : "MMMM D YYYY HH:mm",
                 LLLL : "dddd, D MMMM YYYY HH:mm"
             },
+            meridiem : {
+                AM : 'AM',
+                am : 'am',
+                PM : 'PM',
+                pm : 'pm'
+            },
             relativeTime : {
                 future : "over %s",
                 past : "%s geleden",
index b414c951286ea09d892a01cfdc01242a8269fd0a..ad7fae55269d655b2a52e060b07e263b65bce478 100644 (file)
             LLL : "D MMMM YYYY HH:mm",
             LLLL : "dddd, D MMMM YYYY HH:mm"
         },
+        meridiem : {
+            AM : 'AM',
+            am : 'am',
+            PM : 'PM',
+            pm : 'pm'
+        },
         relativeTime : {
             future : "za %s",
             past : "%s temu",
index 46df22771bc520433e444fc4c0314b1261b5931e..1f1464a4a2aded69464d56c9e5ff80f2e9146020 100644 (file)
                 LLL : "D \\de MMMM \\de YYYY HH:mm",
                 LLLL : "dddd, D \\de MMMM \\de YYYY HH:mm"
             },
+            meridiem : {
+                AM : 'AM',
+                am : 'am',
+                PM : 'PM',
+                pm : 'pm'
+            },
             relativeTime : {
                 future : "em %s",
                 past : "%s atrás",
index c79e8fb30b92c22b7d4dd24e0074ec17fdee74c8..584b56b945d2adeac53a6ca33940d644b8a74ac4 100644 (file)
                 LLL : "D MMMM YYYY HH:mm",
                 LLLL : "dddd D MMMM YYYY HH:mm"
             },
+            meridiem : {
+                AM : 'AM',
+                am : 'am',
+                PM : 'PM',
+                pm : 'pm'
+            },
             relativeTime : {
                 future : "om %s",
                 past : "för %s sen",
index aecaebdd0b12cde62fb01baa51b680489d5b1909..6c7b2e8e90920f8fc1f04691f1346e2db119a716 100644 (file)
--- a/moment.js
+++ b/moment.js
@@ -11,7 +11,7 @@
         round = Math.round,
         languages = {},
         hasModule = (typeof module !== 'undefined'),
-        paramsToParse = 'months|monthsShort|weekdays|weekdaysShort|longDateFormat|relativeTime|ordinal'.split('|'),
+        paramsToParse = 'months|monthsShort|weekdays|weekdaysShort|longDateFormat|relativeTime|ordinal|meridiem'.split('|'),
         i,
         VERSION = "1.1.1",
         shortcuts = 'Month|Date|Hours|Minutes|Seconds'.split('|');
@@ -79,7 +79,8 @@
             charactersToReplace = /(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?|LL?L?L?)/g,
             nonuppercaseLetters = /[^A-Z]/g,
             timezoneRegex = /\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g,
-            ordinal = moment.ordinal;
+            ordinal = moment.ordinal,
+            meridiem = moment.meridiem;
         // check if the character is a format
         // return formatted string or non string.
         //
                 return currentYear;
             // AM / PM
             case 'a' :
-                return currentHours > 11 ? 'pm' : 'am';
+                return currentHours > 11 ? meridiem.pm : meridiem.am;
             case 'A' :
-                return currentHours > 11 ? 'PM' : 'AM';
+                return currentHours > 11 ? meridiem.PM : meridiem.AM;
             // 24 HOUR
             case 'H' :
                 return currentHours;
             LLL : "MMMM D YYYY h:mm A",
             LLLL : "dddd, MMMM D YYYY h:mm A"
         },
+        meridian : {
+            AM : 'AM',
+            am : 'am',
+            PM : 'PM',
+            pm : 'pm'
+        },
         relativeTime : {
             future : "in %s",
             past : "%s ago",
index 774ac81d9aaed44e35128b001bad3bfa47364fc9..4910c999a6a055b744d2df052b1e03ebbabb8f3f 100644 (file)
@@ -123,6 +123,8 @@ block content
           a(href="#/custom/longDateFormats") Long Date Formats
         li
           a(href="#/custom/relativeTime") Relative Time
+        li
+          a(href="#/custom/meridiem") AM/PM
         li
           a(href="#/custom/ordinal") Ordinal
     #docs
@@ -1009,12 +1011,25 @@ block content
         | (The reason for the inverted logic is because the default behavior is to display with the suffix.)
 
 
+      a(name="/custom/meridiem")
+      h3
+        span AM/PM
+      p
+        code moment.meridiem
+        |  should be a map of upper and lowercase versions of am/pm.
+      pre moment.meridiem = {\n
+        |     am : 'am',
+        |     AM : 'AM',
+        |     pm : 'pm',
+        |     PM : 'PM'
+        | };
+
       a(name="/custom/ordinal")
       h3
         span Ordinal
       p
         code moment.ordinal
-        | should be a function that returns the ordinal for a given number.
+        |  should be a function that returns the ordinal for a given number.
       pre moment.ordinal = function (number) {\n
         |     var b = number % 10;
         |     return (~~ (number % 100 / 10) === 1) ? 'th' :