From: Tim Wood Date: Tue, 15 Nov 2011 17:41:24 +0000 (-0800) Subject: Adding customization options for am/pm strings #67 X-Git-Tag: 1.1.2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52216a525ba4f6a2bd1eb85a9d99b17823da3a59;p=thirdparty%2Fmoment.git Adding customization options for am/pm strings #67 --- diff --git a/lang/de.js b/lang/de.js index 27ea9c920..e8ab0a29b 100644 --- a/lang/de.js +++ b/lang/de.js @@ -10,6 +10,12 @@ 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", diff --git a/lang/es.js b/lang/es.js index 53b781c4f..f0ebc3f04 100644 --- a/lang/es.js +++ b/lang/es.js @@ -10,6 +10,12 @@ 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", diff --git a/lang/fr.js b/lang/fr.js index 5e3aeccdb..ad84ed53f 100644 --- a/lang/fr.js +++ b/lang/fr.js @@ -10,6 +10,12 @@ 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", diff --git a/lang/it.js b/lang/it.js index 68281bb00..3c83cf8cc 100644 --- a/lang/it.js +++ b/lang/it.js @@ -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", diff --git a/lang/nb.js b/lang/nb.js index 8bd8a66ea..c8407ccb8 100644 --- a/lang/nb.js +++ b/lang/nb.js @@ -10,6 +10,12 @@ 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", diff --git a/lang/nl.js b/lang/nl.js index 86b72910f..9470b00b5 100644 --- a/lang/nl.js +++ b/lang/nl.js @@ -10,6 +10,12 @@ 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", diff --git a/lang/pl.js b/lang/pl.js index b414c9512..ad7fae552 100644 --- a/lang/pl.js +++ b/lang/pl.js @@ -32,6 +32,12 @@ 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", diff --git a/lang/pt.js b/lang/pt.js index 46df22771..1f1464a4a 100644 --- a/lang/pt.js +++ b/lang/pt.js @@ -10,6 +10,12 @@ 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", diff --git a/lang/sv.js b/lang/sv.js index c79e8fb30..584b56b94 100644 --- a/lang/sv.js +++ b/lang/sv.js @@ -10,6 +10,12 @@ 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", diff --git a/moment.js b/moment.js index aecaebdd0..6c7b2e8e9 100644 --- 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. // @@ -144,9 +145,9 @@ 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; @@ -362,6 +363,12 @@ 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", diff --git a/sitesrc/docs.jade b/sitesrc/docs.jade index 774ac81d9..4910c999a 100644 --- a/sitesrc/docs.jade +++ b/sitesrc/docs.jade @@ -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' :