12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- var buildFormattingTokensRegExp = require('../../_lib/build_formatting_tokens_reg_exp/index.js')
- function buildFormatLocale () {
- var months3char = ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월']
- var monthsFull = ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월']
- var weekdays2char = ['일', '월', '화', '수', '목', '금', '토']
- var weekdays3char = ['일', '월', '화', '수', '목', '금', '토']
- var weekdaysFull = ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일']
- var meridiemUppercase = ['오전', '오후']
- var meridiemLowercase = ['오전', '오후']
- var meridiemFull = ['오전', '오후']
- var formatters = {
- // Month: Jan, Feb, ..., Dec
- 'MMM': function (date) {
- return months3char[date.getMonth()]
- },
- // Month: January, February, ..., December
- 'MMMM': function (date) {
- return monthsFull[date.getMonth()]
- },
- // Day of week: Su, Mo, ..., Sa
- 'dd': function (date) {
- return weekdays2char[date.getDay()]
- },
- // Day of week: Sun, Mon, ..., Sat
- 'ddd': function (date) {
- return weekdays3char[date.getDay()]
- },
- // Day of week: Sunday, Monday, ..., Saturday
- 'dddd': function (date) {
- return weekdaysFull[date.getDay()]
- },
- // AM, PM
- 'A': function (date) {
- return (date.getHours() / 12) >= 1 ? meridiemUppercase[1] : meridiemUppercase[0]
- },
- // am, pm
- 'a': function (date) {
- return (date.getHours() / 12) >= 1 ? meridiemLowercase[1] : meridiemLowercase[0]
- },
- // a.m., p.m.
- 'aa': function (date) {
- return (date.getHours() / 12) >= 1 ? meridiemFull[1] : meridiemFull[0]
- }
- }
- // Generate ordinal version of formatters: M -> Mo, D -> Do, etc.
- var ordinalFormatters = ['M', 'D', 'DDD', 'd', 'Q', 'W']
- ordinalFormatters.forEach(function (formatterToken) {
- formatters[formatterToken + 'o'] = function (date, formatters) {
- return ordinal(formatters[formatterToken](date))
- }
- })
- return {
- formatters: formatters,
- formattingTokensRegExp: buildFormattingTokensRegExp(formatters)
- }
- }
- function ordinal (number) {
- return number + '일'
- }
- module.exports = buildFormatLocale
|