index.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _index = _interopRequireDefault(require("../../../_lib/buildLocalizeFn/index.js"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. var eraValues = {
  9. narrow: ['前', '公元'],
  10. abbreviated: ['前', '公元'],
  11. wide: ['公元前', '公元']
  12. };
  13. var quarterValues = {
  14. narrow: ['1', '2', '3', '4'],
  15. abbreviated: ['第一刻', '第二刻', '第三刻', '第四刻'],
  16. wide: ['第一刻钟', '第二刻钟', '第三刻钟', '第四刻钟']
  17. };
  18. var monthValues = {
  19. narrow: ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'],
  20. abbreviated: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
  21. wide: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
  22. };
  23. var dayValues = {
  24. narrow: ['日', '一', '二', '三', '四', '五', '六'],
  25. short: ['日', '一', '二', '三', '四', '五', '六'],
  26. abbreviated: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
  27. wide: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
  28. };
  29. var dayPeriodValues = {
  30. narrow: {
  31. am: '上',
  32. pm: '下',
  33. midnight: '凌晨',
  34. noon: '午',
  35. morning: '早',
  36. afternoon: '下午',
  37. evening: '晚',
  38. night: '夜'
  39. },
  40. abbreviated: {
  41. am: '上午',
  42. pm: '下午',
  43. midnight: '凌晨',
  44. noon: '中午',
  45. morning: '早晨',
  46. afternoon: '中午',
  47. evening: '晚上',
  48. night: '夜间'
  49. },
  50. wide: {
  51. am: '上午',
  52. pm: '下午',
  53. midnight: '凌晨',
  54. noon: '中午',
  55. morning: '早晨',
  56. afternoon: '中午',
  57. evening: '晚上',
  58. night: '夜间'
  59. }
  60. };
  61. var formattingDayPeriodValues = {
  62. narrow: {
  63. am: '上',
  64. pm: '下',
  65. midnight: '凌晨',
  66. noon: '午',
  67. morning: '早',
  68. afternoon: '下午',
  69. evening: '晚',
  70. night: '夜'
  71. },
  72. abbreviated: {
  73. am: '上午',
  74. pm: '下午',
  75. midnight: '凌晨',
  76. noon: '中午',
  77. morning: '早晨',
  78. afternoon: '中午',
  79. evening: '晚上',
  80. night: '夜间'
  81. },
  82. wide: {
  83. am: '上午',
  84. pm: '下午',
  85. midnight: '凌晨',
  86. noon: '中午',
  87. morning: '早晨',
  88. afternoon: '中午',
  89. evening: '晚上',
  90. night: '夜间'
  91. }
  92. };
  93. function ordinalNumber(dirtyNumber, dirtyOptions) {
  94. // If ordinal numbers depend on context, for example,
  95. // if they are different for different grammatical genders,
  96. // use `options.unit`:
  97. //
  98. // var options = dirtyOptions || {}
  99. // var unit = String(options.unit)
  100. //
  101. // where `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
  102. // 'day', 'hour', 'minute', 'second'
  103. var number = Number(dirtyNumber);
  104. var options = dirtyOptions || {};
  105. var unit = String(options.unit);
  106. switch (unit) {
  107. case 'date':
  108. return number.toString() + '日';
  109. case 'hour':
  110. return number.toString() + '时';
  111. case 'minute':
  112. return number.toString() + '分';
  113. case 'second':
  114. return number.toString() + '秒';
  115. default:
  116. return '第 ' + number.toString();
  117. }
  118. }
  119. var localize = {
  120. ordinalNumber: ordinalNumber,
  121. era: (0, _index.default)({
  122. values: eraValues,
  123. defaultWidth: 'wide'
  124. }),
  125. quarter: (0, _index.default)({
  126. values: quarterValues,
  127. defaultWidth: 'wide',
  128. argumentCallback: function (quarter) {
  129. return Number(quarter) - 1;
  130. }
  131. }),
  132. month: (0, _index.default)({
  133. values: monthValues,
  134. defaultWidth: 'wide'
  135. }),
  136. day: (0, _index.default)({
  137. values: dayValues,
  138. defaultWidth: 'wide'
  139. }),
  140. dayPeriod: (0, _index.default)({
  141. values: dayPeriodValues,
  142. defaultWidth: 'wide',
  143. formattingValues: formattingDayPeriodValues,
  144. defaultFormattingWidth: 'wide'
  145. })
  146. };
  147. var _default = localize;
  148. exports.default = _default;
  149. module.exports = exports.default;