Skip to content

Commit

Permalink
fixed test case for chinese/japanese
Browse files Browse the repository at this point in the history
  • Loading branch information
baryon committed Mar 23, 2012
1 parent 99f6663 commit d75cdac
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 63 deletions.
12 changes: 6 additions & 6 deletions lang/jp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
weekdaysShort : "日_月_火_水_木_金_土".split("_"),
longDateFormat : {
LT : "Ah:mm",
L : "YY/MM/DD",
LL : "YYYY/MM/DD",
LLL : "YYYY年MoDo LT",
LLLL : "YYYY年MoDodddd LT"
L : "YYYY/MM/DD",
LL : "YYYY年M月D日",
LLL : "YYYY年M月D日 LT",
LLLL : "YYYY年M月D日 dddd LT"
},
meridiem : {
AM : '午前',
Expand All @@ -26,7 +26,7 @@
sameElse : 'L'
},
relativeTime : {
future : "%",
future : "%s後",
past : "%s前",
s : "数秒",
m : "1分",
Expand All @@ -36,7 +36,7 @@
d : "1日",
dd : "%d日",
M : "1ヶ月",
MM : "%ヶ月",
MM : "%dヶ月",
y : "1年",
yy : "%d年"
},
Expand Down
10 changes: 5 additions & 5 deletions lang/zh-cn.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
(function () {
var lang = {
months : "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),
monthsShort : "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),
monthsShort : "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
weekdays : "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),
weekdaysShort : "周日_周一_周二_周三_周四_周五_周六".split("_"),
longDateFormat : {
LT : "Ah:mm",
L : "YY/MM/DD",
LL : "YYYY/MM/DD",
LLL : "YYYY年MMoDo LT",
LLLL : "YYYY年MMoDodddd LT"
L : "YYYY/MM/DD",
LL : "YYYY年M月D日",
LLL : "YYYY年M月D日 LT",
LLLL : "YYYY年M月D日 dddd LT"
},
meridiem : {
AM : '上午',
Expand Down
10 changes: 5 additions & 5 deletions lang/zh-tw.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
(function () {
var lang = {
months : "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),
monthsShort : "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),
monthsShort : "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
weekdays : "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),
weekdaysShort : "週日_週一_週二_週三_週四_週五_週六".split("_"),
longDateFormat : {
LT : "Ah:mm",
L : "YY/MM/DD",
LL : "YYYY/MM/DD",
LLL : "YYYY年MMoDo LT",
LLLL : "YYYY年MMoDodddd LT"
L : "YYYY/MM/DD",
LL : "YYYY年M月D日",
LLL : "YYYY年M月D日 LT",
LLLL : "YYYY年M月D日 dddd LT"
},
meridiem : {
AM : '上午',
Expand Down
2 changes: 1 addition & 1 deletion min/lang-all.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions min/lang/jp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion min/lang/zh-cn.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion min/lang/zh-tw.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion min/moment.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions min/moment.min.pretty.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
return a != null ? (this._d["set" + c + b](a), this) : this._d["get" + c + b]();
};
}
var c, d = Math.round, e = {}, f = typeof module != "undefined", g = "months|monthsShort|monthsParse|weekdays|weekdaysShort|longDateFormat|calendar|relativeTime|ordinal|meridiem".split("|"), h, i = /^\/?Date\((\-?\d+)/i, j = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?|ZZ?|LT|LL?L?L?)/g, k = /[^A-Z]/g, l = /\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g, m = /(\\)?(MM?M?M?|dd?d?d|DD?D?D?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|ZZ?|T)/g, n = /(\\)?([0-9]+|([a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+|([\+\-]\d\d:?\d\d))/gi, o = /\d{4}.\d\d.\d\d(T(\d\d(.\d\d(.\d\d)?)?)?([\+\-]\d\d:?\d\d)?)?/, p = "YYYY-MM-DDTHH:mm:ssZ", q = [ [ "HH:mm:ss", /T\d\d:\d\d:\d\d/ ], [ "HH:mm", /T\d\d:\d\d/ ], [ "HH", /T\d\d/ ] ], r = /([\+\-]|\d\d)/gi, s = "1.5.0", t = "Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|");
var c, d = Math.round, e = {}, f = typeof module != "undefined", g = "months|monthsShort|monthsParse|weekdays|weekdaysShort|longDateFormat|calendar|relativeTime|ordinal|meridiem".split("|"), h, i = /^\/?Date\((\-?\d+)/i, j = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?|ZZ?|LT|LL?L?L?)/g, k = /[^A-Z]/g, l = /\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g, m = /(\\)?(MM?M?M?|dd?d?d|DD?D?D?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|ZZ?|T)/g, n = /(\\)?([0-9]+|([a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+|([\+\-]\d\d:?\d\d))/gi, o = /^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d)?)?)?([\+\-]\d\d:?\d\d)?)?/, p = "YYYY-MM-DDTHH:mm:ssZ", q = [ [ "HH:mm:ss", /T\d\d:\d\d:\d\d/ ], [ "HH:mm", /T\d\d:\d\d/ ], [ "HH", /T\d\d/ ] ], r = /([\+\-]|\d\d)/gi, s = "1.5.0", t = "Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|");
c = function(c, d) {
if (c === null || c === "") return null;
var e, f;
Expand Down Expand Up @@ -337,7 +337,7 @@
return this.zone() < c([ this.year() ]).zone() || this.zone() < c([ this.year(), 5 ]).zone();
},
day: function(a) {
var b = this._d.getDay();
var b = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
return a == null ? b : this.add({
d: a - b
});
Expand Down
28 changes: 14 additions & 14 deletions test/lang/jp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports["lang:jp"] = {
"parse" : function(test) {
test.expect(96);
moment.lang('jp');
var tests = '一月 一月_二月 二月_三月 三月_四月 四月_五月 五月_六月 六月_七月 七月_八月 八月_九月 九月_十月 十月_十一月 十一月_十二月 十二月'.split("_");
var tests = '1月 1月_2月 2月_3月 3月_4月 4月_5月 5月_6月 6月_7月 7月_8月 8月_9月 9月_10月 10月_11月 11月_12月 12月'.split("_");
var i;
function equalTest(input, mmm, i) {
test.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
Expand All @@ -32,9 +32,9 @@ exports["lang:jp"] = {
test.expect(18);
moment.lang('jp');
var a = [
['dddd, MMMM Do YYYY, a h:mm:ss', '日曜日, 二月 14 2010, 午後 3:25:50'],
['dddd, MMMM Do YYYY, a h:mm:ss', '日曜日, 2月 14 2010, 午後 3:25:50'],
['ddd, Ah', '日, 午後3'],
['M Mo MM MMMM MMM', '2 2 02 二月 二月'],
['M Mo MM MMMM MMM', '2 2 02 2月 2月'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14 14'],
['d do dddd ddd', '0 0 日曜日 日'],
Expand All @@ -46,10 +46,10 @@ exports["lang:jp"] = {
['s ss', '50 50'],
['a A', '午後 午後'],
['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45 day of the year'],
['L', '14/02/2010'],
['LL', '14 二月 2010'],
['LLL', '14 二月 2010 3:25 午後'],
['LLLL', '日曜日, 14 二月 2010 3:25 午後']
['L', '2010/02/14'],
['LL', '2010年2月14日'],
['LLL', '2010年2月14日 午後3:25'],
['LLLL', '2010年2月14日 日曜日 午後3:25']
],
b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
i;
Expand All @@ -62,7 +62,7 @@ exports["lang:jp"] = {
"format month" : function(test) {
test.expect(12);
moment.lang('jp');
var expected = '一月 一月_二月 二月_三月 三月_四月 四月_五月 五月_六月 六月_七月 七月_八月 八月_九月 九月_十月 十月_十一月 十一月_十二月 十二月'.split("_");
var expected = '1月 1月_2月 2月_3月 3月_4月 4月_5月 5月_6月 6月_7月 7月_8月 8月_9月 9月_10月 10月_11月 11月_12月 12月'.split("_");
var i;
for (i = 0; i < expected.length; i++) {
test.equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
Expand Down Expand Up @@ -147,12 +147,12 @@ exports["lang:jp"] = {

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
28 changes: 14 additions & 14 deletions test/lang/zh-cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ exports["lang:zh-cn"] = {
"parse" : function(test) {
test.expect(96);
moment.lang('zh-cn');
var tests = '一月 一月_二月 二月_三月 三月_四月 四月_五月 五月_六月 六月_七月 七月_八月 八月_九月 九月_十月 十月_十一月 十一月_十二月 十二月'.split("_");
var tests = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split("_");
var i;
function equalTest(input, mmm, i) {
test.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
}
for (i = 0; i < 12; i++) {
tests[i] = tests[i].split(' ');
tests[i] = tests[i].split(' ');console.log(tests[i]);
equalTest(tests[i][0], 'MMM', i);
equalTest(tests[i][1], 'MMM', i);
equalTest(tests[i][0], 'MMMM', i);
Expand All @@ -34,7 +34,7 @@ exports["lang:zh-cn"] = {
var a = [
['dddd, MMMM Do YYYY, a h:mm:ss', '星期日, 二月 14 2010, 下午 3:25:50'],
['ddd, Ah', '周日, 下午3'],
['M Mo MM MMMM MMM', '2 2 02 二月 二月'],
['M Mo MM MMMM MMM', '2 2 02 二月 2月'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14 14'],
['d do dddd ddd', '0 0 星期日 周日'],
Expand All @@ -46,10 +46,10 @@ exports["lang:zh-cn"] = {
['s ss', '50 50'],
['a A', '下午 下午'],
['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45 day of the year'],
['L', '14/02/2010'],
['LL', '14 二月 2010'],
['LLL', '14 二月 2010 3:25 下午'],
['LLLL', '星期日, 14 二月 2010 3:25 下午']
['L', '2010/02/14'],
['LL', '2010年2月14日'],
['LLL', '2010年2月14日 下午3:25'],
['LLLL', '2010年2月14日 星期日 下午3:25']
],
b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
i;
Expand All @@ -62,7 +62,7 @@ exports["lang:zh-cn"] = {
"format month" : function(test) {
test.expect(12);
moment.lang('zh-cn');
var expected = '一月 一月_二月 二月_三月 三月_四月 四月_五月 五月_六月 六月_七月 七月_八月 八月_九月 九月_十月 十月_十一月 十一月_十二月 十二月'.split("_");
var expected = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split("_");
var i;
for (i = 0; i < expected.length; i++) {
test.equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
Expand Down 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
Loading

0 comments on commit d75cdac

Please sign in to comment.