gu.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //! moment.js locale configuration
  2. //! locale : Gujarati [gu]
  3. //! author : Kaushik Thanki : https://github.com/Kaushik1987
  4. ;(function (global, factory) {
  5. typeof exports === 'object' && typeof module !== 'undefined'
  6. && typeof require === 'function' ? factory(require('../moment')) :
  7. typeof define === 'function' && define.amd ? define(['../moment'], factory) :
  8. factory(global.moment)
  9. }(this, (function (moment) { 'use strict';
  10. //! moment.js locale configuration
  11. var symbolMap = {
  12. 1: '૧',
  13. 2: '૨',
  14. 3: '૩',
  15. 4: '૪',
  16. 5: '૫',
  17. 6: '૬',
  18. 7: '૭',
  19. 8: '૮',
  20. 9: '૯',
  21. 0: '૦',
  22. },
  23. numberMap = {
  24. '૧': '1',
  25. '૨': '2',
  26. '૩': '3',
  27. '૪': '4',
  28. '૫': '5',
  29. '૬': '6',
  30. '૭': '7',
  31. '૮': '8',
  32. '૯': '9',
  33. '૦': '0',
  34. };
  35. var gu = moment.defineLocale('gu', {
  36. months: 'જાન્યુઆરી_ફેબ્રુઆરી_માર્ચ_એપ્રિલ_મે_જૂન_જુલાઈ_ઑગસ્ટ_સપ્ટેમ્બર_ઑક્ટ્બર_નવેમ્બર_ડિસેમ્બર'.split(
  37. '_'
  38. ),
  39. monthsShort:
  40. 'જાન્યુ._ફેબ્રુ._માર્ચ_એપ્રિ._મે_જૂન_જુલા._ઑગ._સપ્ટે._ઑક્ટ્._નવે._ડિસે.'.split(
  41. '_'
  42. ),
  43. monthsParseExact: true,
  44. weekdays: 'રવિવાર_સોમવાર_મંગળવાર_બુધ્વાર_ગુરુવાર_શુક્રવાર_શનિવાર'.split(
  45. '_'
  46. ),
  47. weekdaysShort: 'રવિ_સોમ_મંગળ_બુધ્_ગુરુ_શુક્ર_શનિ'.split('_'),
  48. weekdaysMin: 'ર_સો_મં_બુ_ગુ_શુ_શ'.split('_'),
  49. longDateFormat: {
  50. LT: 'A h:mm વાગ્યે',
  51. LTS: 'A h:mm:ss વાગ્યે',
  52. L: 'DD/MM/YYYY',
  53. LL: 'D MMMM YYYY',
  54. LLL: 'D MMMM YYYY, A h:mm વાગ્યે',
  55. LLLL: 'dddd, D MMMM YYYY, A h:mm વાગ્યે',
  56. },
  57. calendar: {
  58. sameDay: '[આજ] LT',
  59. nextDay: '[કાલે] LT',
  60. nextWeek: 'dddd, LT',
  61. lastDay: '[ગઇકાલે] LT',
  62. lastWeek: '[પાછલા] dddd, LT',
  63. sameElse: 'L',
  64. },
  65. relativeTime: {
  66. future: '%s મા',
  67. past: '%s પહેલા',
  68. s: 'અમુક પળો',
  69. ss: '%d સેકંડ',
  70. m: 'એક મિનિટ',
  71. mm: '%d મિનિટ',
  72. h: 'એક કલાક',
  73. hh: '%d કલાક',
  74. d: 'એક દિવસ',
  75. dd: '%d દિવસ',
  76. M: 'એક મહિનો',
  77. MM: '%d મહિનો',
  78. y: 'એક વર્ષ',
  79. yy: '%d વર્ષ',
  80. },
  81. preparse: function (string) {
  82. return string.replace(/[૧૨૩૪૫૬૭૮૯૦]/g, function (match) {
  83. return numberMap[match];
  84. });
  85. },
  86. postformat: function (string) {
  87. return string.replace(/\d/g, function (match) {
  88. return symbolMap[match];
  89. });
  90. },
  91. // Gujarati notation for meridiems are quite fuzzy in practice. While there exists
  92. // a rigid notion of a 'Pahar' it is not used as rigidly in modern Gujarati.
  93. meridiemParse: /રાત|બપોર|સવાર|સાંજ/,
  94. meridiemHour: function (hour, meridiem) {
  95. if (hour === 12) {
  96. hour = 0;
  97. }
  98. if (meridiem === 'રાત') {
  99. return hour < 4 ? hour : hour + 12;
  100. } else if (meridiem === 'સવાર') {
  101. return hour;
  102. } else if (meridiem === 'બપોર') {
  103. return hour >= 10 ? hour : hour + 12;
  104. } else if (meridiem === 'સાંજ') {
  105. return hour + 12;
  106. }
  107. },
  108. meridiem: function (hour, minute, isLower) {
  109. if (hour < 4) {
  110. return 'રાત';
  111. } else if (hour < 10) {
  112. return 'સવાર';
  113. } else if (hour < 17) {
  114. return 'બપોર';
  115. } else if (hour < 20) {
  116. return 'સાંજ';
  117. } else {
  118. return 'રાત';
  119. }
  120. },
  121. week: {
  122. dow: 0, // Sunday is the first day of the week.
  123. doy: 6, // The week that contains Jan 6th is the first week of the year.
  124. },
  125. });
  126. return gu;
  127. })));