index.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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/isSameUTCWeek/index.js"));
  8. var accusativeWeekdays = ['воскресенье', 'понедельник', 'вторник', 'среду', 'четверг', 'пятницу', 'субботу'];
  9. function _lastWeek(day) {
  10. var weekday = accusativeWeekdays[day];
  11. switch (day) {
  12. case 0:
  13. return "'в прошлое " + weekday + " в' p";
  14. case 1:
  15. case 2:
  16. case 4:
  17. return "'в прошлый " + weekday + " в' p";
  18. case 3:
  19. case 5:
  20. case 6:
  21. return "'в прошлую " + weekday + " в' p";
  22. }
  23. }
  24. function thisWeek(day) {
  25. var weekday = accusativeWeekdays[day];
  26. if (day === 2 /* Tue */) {
  27. return "'во " + weekday + " в' p";
  28. } else {
  29. return "'в " + weekday + " в' p";
  30. }
  31. }
  32. function _nextWeek(day) {
  33. var weekday = accusativeWeekdays[day];
  34. switch (day) {
  35. case 0:
  36. return "'в следующее " + weekday + " в' p";
  37. case 1:
  38. case 2:
  39. case 4:
  40. return "'в следующий " + weekday + " в' p";
  41. case 3:
  42. case 5:
  43. case 6:
  44. return "'в следующую " + weekday + " в' p";
  45. }
  46. }
  47. var formatRelativeLocale = {
  48. lastWeek: function lastWeek(date, baseDate, options) {
  49. var day = date.getUTCDay();
  50. if ((0, _index.default)(date, baseDate, options)) {
  51. return thisWeek(day);
  52. } else {
  53. return _lastWeek(day);
  54. }
  55. },
  56. yesterday: "'вчера в' p",
  57. today: "'сегодня в' p",
  58. tomorrow: "'завтра в' p",
  59. nextWeek: function nextWeek(date, baseDate, options) {
  60. var day = date.getUTCDay();
  61. if ((0, _index.default)(date, baseDate, options)) {
  62. return thisWeek(day);
  63. } else {
  64. return _nextWeek(day);
  65. }
  66. },
  67. other: 'P'
  68. };
  69. var formatRelative = function formatRelative(token, date, baseDate, options) {
  70. var format = formatRelativeLocale[token];
  71. if (typeof format === 'function') {
  72. return format(date, baseDate, options);
  73. }
  74. return format;
  75. };
  76. var _default = formatRelative;
  77. exports.default = _default;
  78. module.exports = exports.default;