index.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = void 0;
  7. var _index = _interopRequireDefault(require("../../../_lib/buildLocalizeFn/index.js"));
  8. var eraValues = {
  9. narrow: ['B', 'A'],
  10. abbreviated: ['BC', 'AD'],
  11. wide: ['Before Christ', 'Anno Domini']
  12. };
  13. var quarterValues = {
  14. narrow: ['1', '2', '3', '4'],
  15. abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
  16. wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
  17. };
  18. // Note: in English, the names of days of the week and months are capitalized.
  19. // If you are making a new locale based on this one, check if the same is true for the language you're working on.
  20. // Generally, formatted dates should look like they are in the middle of a sentence,
  21. // e.g. in Spanish language the weekdays and months should be in the lowercase.
  22. var monthValues = {
  23. narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
  24. abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  25. wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
  26. };
  27. var dayValues = {
  28. narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
  29. short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
  30. abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
  31. wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
  32. };
  33. var dayPeriodValues = {
  34. narrow: {
  35. am: 'a',
  36. pm: 'p',
  37. midnight: 'mi',
  38. noon: 'n',
  39. morning: 'morning',
  40. afternoon: 'afternoon',
  41. evening: 'evening',
  42. night: 'night'
  43. },
  44. abbreviated: {
  45. am: 'AM',
  46. pm: 'PM',
  47. midnight: 'midnight',
  48. noon: 'noon',
  49. morning: 'morning',
  50. afternoon: 'afternoon',
  51. evening: 'evening',
  52. night: 'night'
  53. },
  54. wide: {
  55. am: 'a.m.',
  56. pm: 'p.m.',
  57. midnight: 'midnight',
  58. noon: 'noon',
  59. morning: 'morning',
  60. afternoon: 'afternoon',
  61. evening: 'evening',
  62. night: 'night'
  63. }
  64. };
  65. var formattingDayPeriodValues = {
  66. narrow: {
  67. am: 'a',
  68. pm: 'p',
  69. midnight: 'mi',
  70. noon: 'n',
  71. morning: 'in the morning',
  72. afternoon: 'in the afternoon',
  73. evening: 'in the evening',
  74. night: 'at night'
  75. },
  76. abbreviated: {
  77. am: 'AM',
  78. pm: 'PM',
  79. midnight: 'midnight',
  80. noon: 'noon',
  81. morning: 'in the morning',
  82. afternoon: 'in the afternoon',
  83. evening: 'in the evening',
  84. night: 'at night'
  85. },
  86. wide: {
  87. am: 'a.m.',
  88. pm: 'p.m.',
  89. midnight: 'midnight',
  90. noon: 'noon',
  91. morning: 'in the morning',
  92. afternoon: 'in the afternoon',
  93. evening: 'in the evening',
  94. night: 'at night'
  95. }
  96. };
  97. var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
  98. var number = Number(dirtyNumber);
  99. // If ordinal numbers depend on context, for example,
  100. // if they are different for different grammatical genders,
  101. // use `options.unit`.
  102. //
  103. // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
  104. // 'day', 'hour', 'minute', 'second'.
  105. var rem100 = number % 100;
  106. if (rem100 > 20 || rem100 < 10) {
  107. switch (rem100 % 10) {
  108. case 1:
  109. return number + 'st';
  110. case 2:
  111. return number + 'nd';
  112. case 3:
  113. return number + 'rd';
  114. }
  115. }
  116. return number + 'th';
  117. };
  118. var localize = {
  119. ordinalNumber: ordinalNumber,
  120. era: (0, _index.default)({
  121. values: eraValues,
  122. defaultWidth: 'wide'
  123. }),
  124. quarter: (0, _index.default)({
  125. values: quarterValues,
  126. defaultWidth: 'wide',
  127. argumentCallback: function argumentCallback(quarter) {
  128. return quarter - 1;
  129. }
  130. }),
  131. month: (0, _index.default)({
  132. values: monthValues,
  133. defaultWidth: 'wide'
  134. }),
  135. day: (0, _index.default)({
  136. values: dayValues,
  137. defaultWidth: 'wide'
  138. }),
  139. dayPeriod: (0, _index.default)({
  140. values: dayPeriodValues,
  141. defaultWidth: 'wide',
  142. formattingValues: formattingDayPeriodValues,
  143. defaultFormattingWidth: 'wide'
  144. })
  145. };
  146. var _default = localize;
  147. exports.default = _default;
  148. module.exports = exports.default;