L : 'YYYY/MM/DD',
LL : 'YYYY年M月D日',
LLL : 'YYYY年M月D日 HH:mm',
- LLLL : 'YYYY年M月D日 HH:mm dddd',
+ LLLL : 'YYYY年M月D日 dddd HH:mm',
l : 'YYYY/MM/DD',
ll : 'YYYY年M月D日',
lll : 'YYYY年M月D日 HH:mm',
- llll : 'YYYY年M月D日 HH:mm dddd'
+ llll : 'YYYY年M月D日(ddd) HH:mm'
},
meridiemParse: /午前|午後/i,
isPM : function (input) {
calendar : {
sameDay : '[今日] LT',
nextDay : '[明日] LT',
- nextWeek : '[来週]dddd LT',
+ nextWeek : function (now) {
+ if (now.week() < this.week()) {
+ return '[来週]dddd LT';
+ } else {
+ return 'dddd LT';
+ }
+ },
lastDay : '[昨日] LT',
- lastWeek : '[前週]dddd LT',
+ lastWeek : function (now) {
+ if (this.week() < now.week()) {
+ return '[先週]dddd LT';
+ } else {
+ return 'dddd LT';
+ }
+ },
sameElse : 'L'
},
dayOfMonthOrdinalParse : /\d{1,2}日/,
['L', '2010/02/14'],
['LL', '2010年2月14日'],
['LLL', '2010年2月14日 15:25'],
- ['LLLL', '2010年2月14日 15:25 日曜日'],
+ ['LLLL', '2010年2月14日 日曜日 15:25'],
['l', '2010/02/14'],
['ll', '2010年2月14日'],
['lll', '2010年2月14日 15:25'],
- ['llll', '2010年2月14日 15:25 日曜日']
+ ['llll', '2010年2月14日(日) 15:25']
],
b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
i;
test('calendar next week', function (assert) {
var i, m;
+ var dow = moment().day();
for (i = 2; i < 7; i++) {
m = moment().add({d: i});
- assert.equal(m.calendar(), m.format('[来週]dddd LT'), 'Today + ' + i + ' days current time');
- m.hours(0).minutes(0).seconds(0).milliseconds(0);
- assert.equal(m.calendar(), m.format('[来週]dddd LT'), 'Today + ' + i + ' days beginning of day');
- m.hours(23).minutes(59).seconds(59).milliseconds(999);
- assert.equal(m.calendar(), m.format('[来週]dddd LT'), 'Today + ' + i + ' days end of day');
+ if (dow + i < 7) {
+ assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days end of day');
+ } else {
+ assert.equal(m.calendar(), m.format('[来週]dddd LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('[来週]dddd LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('[来週]dddd LT'), 'Today + ' + i + ' days end of day');
+ }
}
});
test('calendar last week', function (assert) {
var i, m;
+ var dow = moment().day();
for (i = 2; i < 7; i++) {
m = moment().subtract({d: i});
- assert.equal(m.calendar(), m.format('[前週]dddd LT'), 'Today - ' + i + ' days current time');
- m.hours(0).minutes(0).seconds(0).milliseconds(0);
- assert.equal(m.calendar(), m.format('[前週]dddd LT'), 'Today - ' + i + ' days beginning of day');
- m.hours(23).minutes(59).seconds(59).milliseconds(999);
- assert.equal(m.calendar(), m.format('[前週]dddd LT'), 'Today - ' + i + ' days end of day');
+ if (dow < i) {
+ assert.equal(m.calendar(), m.format('[先週]dddd LT'), 'Today - ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('[先週]dddd LT'), 'Today - ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('[先週]dddd LT'), 'Today - ' + i + ' days end of day');
+ } else {
+ assert.equal(m.calendar(), m.format('dddd LT'), 'Today - ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd LT'), 'Today - ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd LT'), 'Today - ' + i + ' days end of day');
+ }
}
});