index.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var formatDistanceLocale = {
  7. lessThanXSeconds: {
  8. one: 'menos de um segundo',
  9. other: 'menos de {{count}} segundos'
  10. },
  11. xSeconds: {
  12. one: '1 segundo',
  13. other: '{{count}} segundos'
  14. },
  15. halfAMinute: 'meio minuto',
  16. lessThanXMinutes: {
  17. one: 'menos de um minuto',
  18. other: 'menos de {{count}} minutos'
  19. },
  20. xMinutes: {
  21. one: '1 minuto',
  22. other: '{{count}} minutos'
  23. },
  24. aboutXHours: {
  25. one: 'cerca de 1 hora',
  26. other: 'cerca de {{count}} horas'
  27. },
  28. xHours: {
  29. one: '1 hora',
  30. other: '{{count}} horas'
  31. },
  32. xDays: {
  33. one: '1 dia',
  34. other: '{{count}} dias'
  35. },
  36. aboutXWeeks: {
  37. one: 'cerca de 1 semana',
  38. other: 'cerca de {{count}} semanas'
  39. },
  40. xWeeks: {
  41. one: '1 semana',
  42. other: '{{count}} semanas'
  43. },
  44. aboutXMonths: {
  45. one: 'cerca de 1 mês',
  46. other: 'cerca de {{count}} meses'
  47. },
  48. xMonths: {
  49. one: '1 mês',
  50. other: '{{count}} meses'
  51. },
  52. aboutXYears: {
  53. one: 'cerca de 1 ano',
  54. other: 'cerca de {{count}} anos'
  55. },
  56. xYears: {
  57. one: '1 ano',
  58. other: '{{count}} anos'
  59. },
  60. overXYears: {
  61. one: 'mais de 1 ano',
  62. other: 'mais de {{count}} anos'
  63. },
  64. almostXYears: {
  65. one: 'quase 1 ano',
  66. other: 'quase {{count}} anos'
  67. }
  68. };
  69. var formatDistance = function formatDistance(token, count, options) {
  70. var result;
  71. var tokenValue = formatDistanceLocale[token];
  72. if (typeof tokenValue === 'string') {
  73. result = tokenValue;
  74. } else if (count === 1) {
  75. result = tokenValue.one;
  76. } else {
  77. result = tokenValue.other.replace('{{count}}', String(count));
  78. }
  79. if (options !== null && options !== void 0 && options.addSuffix) {
  80. if (options.comparison && options.comparison > 0) {
  81. return 'em ' + result;
  82. } else {
  83. return 'há ' + result;
  84. }
  85. }
  86. return result;
  87. };
  88. var _default = formatDistance;
  89. exports.default = _default;
  90. module.exports = exports.default;