Skip to content

Commit

Permalink
remove am/AM/pm/PM from meridiem
Browse files Browse the repository at this point in the history
Changing to a function.
#222 #228
  • Loading branch information
timrwood committed Mar 23, 2012
1 parent 42d0c81 commit b34ba94
Show file tree
Hide file tree
Showing 22 changed files with 83 additions and 135 deletions.
6 changes: 0 additions & 6 deletions lang/ca.js
Expand Up @@ -11,12 +11,6 @@
LLL : "D MMMM YYYY LT",
LLLL : "dddd D MMMM YYYY LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay : function () {
return '[avui a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
Expand Down
6 changes: 0 additions & 6 deletions lang/da.js
Expand Up @@ -11,12 +11,6 @@
LLL : "D MMMM YYYY h:mm A",
LLLL : "dddd D. MMMM, YYYY h:mm A"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay : '[I dag kl.] LT',
nextDay : '[I morgen kl.] LT',
Expand Down
6 changes: 0 additions & 6 deletions lang/de.js
Expand Up @@ -11,12 +11,6 @@
LLL : "D. MMMM YYYY LT",
LLLL : "dddd, D. MMMM YYYY LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay: "[Heute um] LT",
sameElse: "L",
Expand Down
6 changes: 0 additions & 6 deletions lang/en-gb.js
Expand Up @@ -11,12 +11,6 @@
LLL : "D MMMM YYYY LT",
LLLL : "dddd, D MMMM YYYY LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay : '[Today at] LT',
nextDay : '[Tomorrow at] LT',
Expand Down
6 changes: 0 additions & 6 deletions lang/es.js
Expand Up @@ -11,12 +11,6 @@
LLL : "D MMMM YYYY LT",
LLLL : "dddd D MMMM YYYY LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay : function () {
return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
Expand Down
6 changes: 0 additions & 6 deletions lang/eu.js
Expand Up @@ -11,12 +11,6 @@
LLL : "YYYYko MMMMren D[a] LT",
LLLL : "dddd, YYYYko MMMMren D[a] LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay : '[gaur] LT[etan]',
nextDay : '[bihar] LT[etan]',
Expand Down
6 changes: 0 additions & 6 deletions lang/fi.js
Expand Up @@ -55,12 +55,6 @@
LLL : "Do MMMMt\\a YYYY, klo LT",
LLLL : "dddd, Do MMMMt\\a YYYY, klo LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay : '[tänään] [klo] LT',
nextDay : '[huomenna] [klo] LT',
Expand Down
6 changes: 0 additions & 6 deletions lang/fr.js
Expand Up @@ -11,12 +11,6 @@
LLL : "D MMMM YYYY LT",
LLLL : "dddd D MMMM YYYY LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay: "[Aujourd'hui à] LT",
nextDay: '[Demain à] LT',
Expand Down
6 changes: 0 additions & 6 deletions lang/gl.js
Expand Up @@ -11,12 +11,6 @@
LLL : "D MMMM YYYY LT",
LLLL : "dddd D MMMM YYYY LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay : function () {
return '[hoxe ' + ((this.hours() !== 1) ? 'ás' : 'a') + '] LT';
Expand Down
6 changes: 0 additions & 6 deletions lang/it.js
Expand Up @@ -11,12 +11,6 @@
LLL : "D MMMM YYYY LT",
LLLL : "dddd, D MMMM YYYY LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay: '[Oggi alle] LT',
nextDay: '[Domani alle] LT',
Expand Down
9 changes: 3 additions & 6 deletions lang/kr.js
Expand Up @@ -11,12 +11,9 @@
LLL : "YYYY년 MMMM D일 LT",
LLLL : "YYYY년 MMMM D일 dddd LT"
},
meridiem : {
AM : '오전',
am : '오전',
PM : '오후',
pm : '오후'
},
meridiem : function(hour, minute, isUpper) {
return hour < 12 ? '오전' : '오후';
},
calendar : {
sameDay : '오늘 LT',
nextDay : '내일 LT',
Expand Down
6 changes: 0 additions & 6 deletions lang/nb.js
Expand Up @@ -11,12 +11,6 @@
LLL : "D MMMM YYYY LT",
LLLL : "dddd D MMMM YYYY LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay: '[I dag klokken] LT',
nextDay: '[I morgen klokken] LT',
Expand Down
6 changes: 0 additions & 6 deletions lang/nl.js
Expand Up @@ -11,12 +11,6 @@
LLL : "D MMMM YYYY LT",
LLLL : "dddd D MMMM YYYY LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay: '[Vandaag om] LT',
nextDay: '[Morgen om] LT',
Expand Down
6 changes: 0 additions & 6 deletions lang/pl.js
Expand Up @@ -33,12 +33,6 @@
LLL : "D MMMM YYYY LT",
LLLL : "dddd, D MMMM YYYY LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay: '[Dziś o] LT',
nextDay: '[Jutro o] LT',
Expand Down
6 changes: 0 additions & 6 deletions lang/pt.js
Expand Up @@ -11,12 +11,6 @@
LLL : "D \\de MMMM \\de YYYY LT",
LLLL : "dddd, D \\de MMMM \\de YYYY LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay: '[Hoje às] LT',
nextDay: '[Amanhã às] LT',
Expand Down
6 changes: 0 additions & 6 deletions lang/sv.js
Expand Up @@ -11,12 +11,6 @@
LLL : "D MMMM YYYY LT",
LLLL : "dddd D MMMM YYYY LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay: '[Idag klockan] LT',
nextDay: '[Imorgon klockan] LT',
Expand Down
6 changes: 0 additions & 6 deletions lang/tr.js
Expand Up @@ -11,12 +11,6 @@
LLL : "D MMMM YYYY LT",
LLLL : "dddd, D MMMM YYYY LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay : '[bugün saat] LT',
nextDay : '[yarın saat] LT',
Expand Down
17 changes: 12 additions & 5 deletions lang/zh-cn.js
Expand Up @@ -11,11 +11,18 @@
LLL : "YYYY年MMMMD日LT",
LLLL : "YYYY年MMMMD日ddddLT"
},
meridiem : {
AM : '上午',
am : '上午',
PM : '下午',
pm : '下午'
meridiem : function (hour, minute, isLower) {
if (hour < 9) {
return "早上";
} else if (hour < 11 && minute < 30) {
return "上午";
} else if (hour < 13 && minute < 30) {
return "中午";
} else if (hour < 18) {
return "下午";
} else {
return "晚上";
}
},
calendar : {
sameDay : '[今天]LT',
Expand Down
17 changes: 12 additions & 5 deletions lang/zh-tw.js
Expand Up @@ -11,11 +11,18 @@
LLL : "YYYY年MMMMD日LT",
LLLL : "YYYY年MMMMD日ddddLT"
},
meridiem : {
AM : '上午',
am : '上午',
PM : '下午',
pm : '下午'
meridiem : function (hour, minute, isLower) {
if (hour < 9) {
return "早上";
} else if (hour < 11 && minute < 30) {
return "上午";
} else if (hour < 13 && minute < 30) {
return "中午";
} else if (hour < 18) {
return "下午";
} else {
return "晚上";
}
},
calendar : {
sameDay : '[今天]LT',
Expand Down
13 changes: 4 additions & 9 deletions moment.js
Expand Up @@ -165,9 +165,9 @@
return currentYear;
// AM / PM
case 'a' :
return currentHours > 11 ? meridiem.pm : meridiem.am;
return meridiem ? meridiem(currentHours, currentMinutes, false) : (currentHours > 11 ? 'pm' : 'am');
case 'A' :
return currentHours > 11 ? meridiem.PM : meridiem.AM;
return meridiem ? meridiem(currentHours, currentMinutes, true) : (currentHours > 11 ? 'PM' : 'AM');
// 24 HOUR
case 'H' :
return currentHours;
Expand Down Expand Up @@ -501,7 +501,7 @@
if (languages[key]) {
for (i = 0; i < paramsToParse.length; i++) {
param = paramsToParse[i];
moment[param] = languages[key][param] || moment[param];
moment[param] = languages[key][param] || languages.en[param];
}
} else {
if (hasModule) {
Expand All @@ -524,12 +524,7 @@
LLL : "MMMM D YYYY LT",
LLLL : "dddd, MMMM D YYYY LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
meridiem : false,
calendar : {
sameDay : '[Today at] LT',
nextDay : '[Tomorrow at] LT',
Expand Down
33 changes: 26 additions & 7 deletions test/lang/zh-cn.js
Expand Up @@ -147,12 +147,12 @@ exports["lang:zh-cn"] = {

var a = moment().hours(2).minutes(0).seconds(0);

test.equal(moment(a).calendar(), "今天上午2点00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "今天上午2点25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "今天上午3点00", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "明天上午2点00", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "今天上午1点00", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "昨天上午2点00", "yesterday at the same time");
test.equal(moment(a).calendar(), "今天早上2点00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "今天早上2点25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "今天早上3点00", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "明天早上2点00", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "今天早上1点00", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "昨天早上2点00", "yesterday at the same time");
test.done();
},

Expand Down Expand Up @@ -203,6 +203,25 @@ exports["lang:zh-cn"] = {

test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
test.done();
test.done();
},

"meridiem" : function(test) {
test.expect(10);
moment.lang('zh-cn');

test.equal(moment([2011, 2, 23, 0, 0]).format('a'), "早上", "morning");
test.equal(moment([2011, 2, 23, 9, 0]).format('a'), "上午", "before noon");
test.equal(moment([2011, 2, 23, 12, 0]).format('a'), "中午", "noon");
test.equal(moment([2011, 2, 23, 13, 0]).format('a'), "下午", "after noon");
test.equal(moment([2011, 2, 23, 18, 0]).format('a'), "晚上", "night");

test.equal(moment([2011, 2, 23, 0, 0]).format('A'), "早上", "morning");
test.equal(moment([2011, 2, 23, 9, 0]).format('A'), "上午", "before noon");
test.equal(moment([2011, 2, 23, 12, 0]).format('A'), "中午", "noon");
test.equal(moment([2011, 2, 23, 13, 0]).format('A'), "下午", "afternoon");
test.equal(moment([2011, 2, 23, 18, 0]).format('A'), "晚上", "night");

test.done();
}
};
33 changes: 26 additions & 7 deletions test/lang/zh-tw.js
Expand Up @@ -147,12 +147,12 @@ exports["lang:zh-tw"] = {

var a = moment().hours(2).minutes(0).seconds(0);

test.equal(moment(a).calendar(), "今天上午2點00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "今天上午2點25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "今天上午3點00", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "明天上午2點00", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "今天上午1點00", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "昨天上午2點00", "yesterday at the same time");
test.equal(moment(a).calendar(), "今天早上2點00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "今天早上2點25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "今天早上3點00", "Now plus 1 hour");
test.equal(moment(a).add({ d: 1 }).calendar(), "明天早上2點00", "tomorrow at the same time");
test.equal(moment(a).subtract({ h: 1 }).calendar(), "今天早上1點00", "Now minus 1 hour");
test.equal(moment(a).subtract({ d: 1 }).calendar(), "昨天早上2點00", "yesterday at the same time");
test.done();
},

Expand Down Expand Up @@ -203,6 +203,25 @@ exports["lang:zh-tw"] = {

test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
test.done();
test.done();
},

"meridiem" : function(test) {
test.expect(10);
moment.lang('zh-cn');

test.equal(moment([2011, 2, 23, 0, 0]).format('a'), "早上", "morning");
test.equal(moment([2011, 2, 23, 9, 0]).format('a'), "上午", "before noon");
test.equal(moment([2011, 2, 23, 12, 0]).format('a'), "中午", "noon");
test.equal(moment([2011, 2, 23, 13, 0]).format('a'), "下午", "after noon");
test.equal(moment([2011, 2, 23, 18, 0]).format('a'), "晚上", "night");

test.equal(moment([2011, 2, 23, 0, 0]).format('A'), "早上", "morning");
test.equal(moment([2011, 2, 23, 9, 0]).format('A'), "上午", "before noon");
test.equal(moment([2011, 2, 23, 12, 0]).format('A'), "中午", "noon");
test.equal(moment([2011, 2, 23, 13, 0]).format('A'), "下午", "afternoon");
test.equal(moment([2011, 2, 23, 18, 0]).format('A'), "晚上", "night");

test.done();
}
};

0 comments on commit b34ba94

Please sign in to comment.