You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
4.0 KiB

  1. //! moment.js locale configuration
  2. //! locale : chinese (zh-cn)
  3. //! author : suupic : https://github.com/suupic
  4. //! author : Zeno Zeng : https://github.com/zenozeng
  5. import moment from '../moment';
  6. export default moment.defineLocale('zh-cn', {
  7. months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
  8. monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  9. weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  10. weekdaysShort : '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  11. weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
  12. longDateFormat : {
  13. LT : 'Ah点mm',
  14. LTS : 'Ah点m分s秒',
  15. L : 'YYYY-MM-DD',
  16. LL : 'YYYY年MMMD日',
  17. LLL : 'YYYY年MMMD日LT',
  18. LLLL : 'YYYY年MMMD日ddddLT',
  19. l : 'YYYY-MM-DD',
  20. ll : 'YYYY年MMMD日',
  21. lll : 'YYYY年MMMD日LT',
  22. llll : 'YYYY年MMMD日ddddLT'
  23. },
  24. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  25. meridiemHour: function (hour, meridiem) {
  26. if (hour === 12) {
  27. hour = 0;
  28. }
  29. if (meridiem === '凌晨' || meridiem === '早上' ||
  30. meridiem === '上午') {
  31. return hour;
  32. } else if (meridiem === '下午' || meridiem === '晚上') {
  33. return hour + 12;
  34. } else {
  35. // '中午'
  36. return hour >= 11 ? hour : hour + 12;
  37. }
  38. },
  39. meridiem : function (hour, minute, isLower) {
  40. var hm = hour * 100 + minute;
  41. if (hm < 600) {
  42. return '凌晨';
  43. } else if (hm < 900) {
  44. return '早上';
  45. } else if (hm < 1130) {
  46. return '上午';
  47. } else if (hm < 1230) {
  48. return '中午';
  49. } else if (hm < 1800) {
  50. return '下午';
  51. } else {
  52. return '晚上';
  53. }
  54. },
  55. calendar : {
  56. sameDay : function () {
  57. return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
  58. },
  59. nextDay : function () {
  60. return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
  61. },
  62. lastDay : function () {
  63. return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
  64. },
  65. nextWeek : function () {
  66. var startOfWeek, prefix;
  67. startOfWeek = moment().startOf('week');
  68. prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
  69. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  70. },
  71. lastWeek : function () {
  72. var startOfWeek, prefix;
  73. startOfWeek = moment().startOf('week');
  74. prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
  75. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  76. },
  77. sameElse : 'LL'
  78. },
  79. ordinalParse: /\d{1,2}(日|月|周)/,
  80. ordinal : function (number, period) {
  81. switch (period) {
  82. case 'd':
  83. case 'D':
  84. case 'DDD':
  85. return number + '日';
  86. case 'M':
  87. return number + '月';
  88. case 'w':
  89. case 'W':
  90. return number + '周';
  91. default:
  92. return number;
  93. }
  94. },
  95. relativeTime : {
  96. future : '%s内',
  97. past : '%s前',
  98. s : '几秒',
  99. m : '1分钟',
  100. mm : '%d分钟',
  101. h : '1小时',
  102. hh : '%d小时',
  103. d : '1天',
  104. dd : '%d天',
  105. M : '1个月',
  106. MM : '%d个月',
  107. y : '1年',
  108. yy : '%d年'
  109. },
  110. week : {
  111. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  112. dow : 1, // Monday is the first day of the week.
  113. doy : 4 // The week that contains Jan 4th is the first week of the year.
  114. }
  115. });