pa-in.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //! moment.js locale configuration
  2. //! locale : Punjabi (India) [pa-in]
  3. //! author : Harpreet Singh : https://github.com/harpreetkhalsagtbit
  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 paIn = moment.defineLocale('pa-in', {
  36. // There are months name as per Nanakshahi Calendar but they are not used as rigidly in modern Punjabi.
  37. months: 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split(
  38. '_'
  39. ),
  40. monthsShort: 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split(
  41. '_'
  42. ),
  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. // Punjabi 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 Punjabi.
  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 paIn;
  126. })));