Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the meridiem value for Chinese. #222

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions lang/ca.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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/fr.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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, upperCase) {
return hour > 11 ? '오후' : '오전' ;
},
calendar : {
sameDay : '오늘 LT',
nextDay : '내일 LT',
Expand Down
6 changes: 0 additions & 6 deletions lang/nb.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@
LLL : "D MMMM YYYY LT",
LLLL : "dddd, D MMMM YYYY LT"
},
meridiem : {
AM : '上午',
am : '上午',
PM : '下午',
pm : '下午'
meridiem : function (hour, minute, upperCase) {
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
19 changes: 13 additions & 6 deletions lang/zh-tw.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@
LLL : "D MMMM YYYY LT",
LLLL : "dddd, D MMMM YYYY LT"
},
meridiem : {
AM : '上午',
am : '上午',
PM : '下午',
pm : '下午'
meridiem : function (hour, minute, upperCase) {
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 Expand Up @@ -53,4 +60,4 @@
if (typeof window !== 'undefined' && this.moment && this.moment.lang) {
this.moment.lang('zh-tw', lang);
}
}());
}());
12 changes: 3 additions & 9 deletions moment.js
Original file line number Diff line number Diff line change
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 @@ -500,7 +500,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 @@ -523,12 +523,6 @@
LLL : "MMMM D YYYY LT",
LLLL : "dddd, MMMM D YYYY LT"
},
meridiem : {
AM : 'AM',
am : 'am',
PM : 'PM',
pm : 'pm'
},
calendar : {
sameDay : '[Today at] LT',
nextDay : '[Tomorrow at] LT',
Expand Down
31 changes: 25 additions & 6 deletions test/lang/zh-cn.js
Original file line number Diff line number Diff line change
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 @@ -204,5 +204,24 @@ 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();
},

"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
Original file line number Diff line number Diff line change
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 @@ -204,5 +204,24 @@ 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();
},

"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();
}
};
};