Skip to content

Commit

Permalink
Merge pull request #1362 from jeeeyul/develop
Browse files Browse the repository at this point in the history
Meridiem Parser support for Korean
  • Loading branch information
ichernev committed Dec 21, 2013
2 parents 56abd58 + d9c856a commit 3592974
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lang/ko.js
@@ -1,7 +1,10 @@
// moment.js language configuration
// language : korean (ko)
// author : Kyungwook, Park : https://github.com/kyungw00k

//
// authors
//
// - Kyungwook, Park : https://github.com/kyungw00k
// - Jeeeyul Lee <jeeeyul@gmail.com>
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
Expand Down Expand Up @@ -51,6 +54,10 @@
y : "일년",
yy : "%d년"
},
ordinal : '%d일'
ordinal : '%d일',
meridiemParse : /(오전|오후)/,
isPM : function (token) {
return token === "오후";
}
});
}));
39 changes: 39 additions & 0 deletions test/lang/ko.js
Expand Up @@ -36,6 +36,45 @@ exports["lang:kr"] = {
}
test.done();
},

"parse meridiem" : function (test) {
var elements = [{
expression : "1981년 9월 8일 오후 2시 30분",
inputFormat : "YYYY[년] M[월] D[일] A h[시] m[분]",
outputFormat : "A",
expected : "오후"
}, {
expression : "1981년 9월 8일 오전 2시 30분",
inputFormat : "YYYY[년] M[월] D[일] A h[시] m[분]",
outputFormat : "A h시",
expected : "오전 2시"
}, {
expression : "14시 30분",
inputFormat : "H[시] m[분]",
outputFormat : "A",
expected : "오후"
}, {
expression : "오후 4시",
inputFormat : "A h[시]",
outputFormat : "H",
expected : "16"
}];

test.expect(elements.length);

elements.forEach(function (it) {
var actual = moment(it.expression, it.inputFormat).format(it.outputFormat);

test.equal(
actual,
it.expected,
"'" + it.outputFormat + "' of '" + it.expression + "' must be '" + it.expected + "' but was '" + actual + "'."
);
});

test.done();
},

"format" : function (test) {
test.expect(22);

Expand Down

0 comments on commit 3592974

Please sign in to comment.