gu.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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: 'જાન્યુ._ફેબ્રુ._માર્ચ_એપ્રિ._મે_જૂન_જુલા._ઑગ._સપ્ટે._ઑક્ટ્._નવે._ડિસે.'.split(
  40. '_'
  41. ),
  42. monthsParseExact: true,
  43. weekdays: 'રવિવાર_સોમવાર_મંગળવાર_બુધ્વાર_ગુરુવાર_શુક્રવાર_શનિવાર'.split(
  44. '_'
  45. ),
  46. weekdaysShort: 'રવિ_સોમ_મંગળ_બુધ્_ગુરુ_શુક્ર_શનિ'.split('_'),
  47. weekdaysMin: 'ર_સો_મં_બુ_ગુ_શુ_શ'.split('_'),
  48. longDateFormat: {
  49. LT: 'A h:mm વાગ્યે',
  50. LTS: 'A h:mm:ss વાગ્યે',
  51. L: 'DD/MM/YYYY',
  52. LL: 'D MMMM YYYY',
  53. LLL: 'D MMMM YYYY, A h:mm વાગ્યે',
  54. LLLL: 'dddd, D MMMM YYYY, A h:mm વાગ્યે',
  55. },
  56. calendar: {
  57. sameDay: '[આજ] LT',
  58. nextDay: '[કાલે] LT',
  59. nextWeek: 'dddd, LT',
  60. lastDay: '[ગઇકાલે] LT',
  61. lastWeek: '[પાછલા] dddd, LT',
  62. sameElse: 'L',
  63. },
  64. relativeTime: {
  65. future: '%s મા',
  66. past: '%s પહેલા',
  67. s: 'અમુક પળો',
  68. ss: '%d સેકંડ',
  69. m: 'એક મિનિટ',
  70. mm: '%d મિનિટ',
  71. h: 'એક કલાક',
  72. hh: '%d કલાક',
  73. d: 'એક દિવસ',
  74. dd: '%d દિવસ',
  75. M: 'એક મહિનો',
  76. MM: '%d મહિનો',
  77. y: 'એક વર્ષ',
  78. yy: '%d વર્ષ',
  79. },
  80. preparse: function (string) {
  81. return string.replace(/[૧૨૩૪૫૬૭૮૯૦]/g, function (match) {
  82. return numberMap[match];
  83. });
  84. },
  85. postformat: function (string) {
  86. return string.replace(/\d/g, function (match) {
  87. return symbolMap[match];
  88. });
  89. },
  90. // Gujarati notation for meridiems are quite fuzzy in practice. While there exists
  91. // a rigid notion of a 'Pahar' it is not used as rigidly in modern Gujarati.
  92. meridiemParse: /રાત|બપોર|સવાર|સાંજ/,
  93. meridiemHour: function (hour, meridiem) {
  94. if (hour === 12) {
  95. hour = 0;
  96. }
  97. if (meridiem === 'રાત') {
  98. return hour < 4 ? hour : hour + 12;
  99. } else if (meridiem === 'સવાર') {
  100. return hour;
  101. } else if (meridiem === 'બપોર') {
  102. return hour >= 10 ? hour : hour + 12;
  103. } else if (meridiem === 'સાંજ') {
  104. return hour + 12;
  105. }
  106. },
  107. meridiem: function (hour, minute, isLower) {
  108. if (hour < 4) {
  109. return 'રાત';
  110. } else if (hour < 10) {
  111. return 'સવાર';
  112. } else if (hour < 17) {
  113. return 'બપોર';
  114. } else if (hour < 20) {
  115. return 'સાંજ';
  116. } else {
  117. return 'રાત';
  118. }
  119. },
  120. week: {
  121. dow: 0, // Sunday is the first day of the week.
  122. doy: 6, // The week that contains Jan 6th is the first week of the year.
  123. },
  124. });
  125. return gu;
  126. })));