pa-in.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //! moment.js locale configuration
  2. //! locale : Punjabi (India) [pa-in]
  3. //! author : Harpreet Singh : https://github.com/harpreetkhalsagtbit
  4. import moment from '../moment';
  5. var symbolMap = {
  6. 1: '੧',
  7. 2: '੨',
  8. 3: '੩',
  9. 4: '੪',
  10. 5: '੫',
  11. 6: '੬',
  12. 7: '੭',
  13. 8: '੮',
  14. 9: '੯',
  15. 0: '੦',
  16. },
  17. numberMap = {
  18. '੧': '1',
  19. '੨': '2',
  20. '੩': '3',
  21. '੪': '4',
  22. '੫': '5',
  23. '੬': '6',
  24. '੭': '7',
  25. '੮': '8',
  26. '੯': '9',
  27. '੦': '0',
  28. };
  29. export default moment.defineLocale('pa-in', {
  30. // There are months name as per Nanakshahi Calendar but they are not used as rigidly in modern Punjabi.
  31. months: 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split(
  32. '_'
  33. ),
  34. monthsShort: 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split(
  35. '_'
  36. ),
  37. weekdays: 'ਐਤਵਾਰ_ਸੋਮਵਾਰ_ਮੰਗਲਵਾਰ_ਬੁਧਵਾਰ_ਵੀਰਵਾਰ_ਸ਼ੁੱਕਰਵਾਰ_ਸ਼ਨੀਚਰਵਾਰ'.split(
  38. '_'
  39. ),
  40. weekdaysShort: 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'),
  41. weekdaysMin: 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'),
  42. longDateFormat: {
  43. LT: 'A h:mm ਵਜੇ',
  44. LTS: 'A h:mm:ss ਵਜੇ',
  45. L: 'DD/MM/YYYY',
  46. LL: 'D MMMM YYYY',
  47. LLL: 'D MMMM YYYY, A h:mm ਵਜੇ',
  48. LLLL: 'dddd, D MMMM YYYY, A h:mm ਵਜੇ',
  49. },
  50. calendar: {
  51. sameDay: '[ਅਜ] LT',
  52. nextDay: '[ਕਲ] LT',
  53. nextWeek: '[ਅਗਲਾ] dddd, LT',
  54. lastDay: '[ਕਲ] LT',
  55. lastWeek: '[ਪਿਛਲੇ] dddd, LT',
  56. sameElse: 'L',
  57. },
  58. relativeTime: {
  59. future: '%s ਵਿੱਚ',
  60. past: '%s ਪਿਛਲੇ',
  61. s: 'ਕੁਝ ਸਕਿੰਟ',
  62. ss: '%d ਸਕਿੰਟ',
  63. m: 'ਇਕ ਮਿੰਟ',
  64. mm: '%d ਮਿੰਟ',
  65. h: 'ਇੱਕ ਘੰਟਾ',
  66. hh: '%d ਘੰਟੇ',
  67. d: 'ਇੱਕ ਦਿਨ',
  68. dd: '%d ਦਿਨ',
  69. M: 'ਇੱਕ ਮਹੀਨਾ',
  70. MM: '%d ਮਹੀਨੇ',
  71. y: 'ਇੱਕ ਸਾਲ',
  72. yy: '%d ਸਾਲ',
  73. },
  74. preparse: function (string) {
  75. return string.replace(/[੧੨੩੪੫੬੭੮੯੦]/g, function (match) {
  76. return numberMap[match];
  77. });
  78. },
  79. postformat: function (string) {
  80. return string.replace(/\d/g, function (match) {
  81. return symbolMap[match];
  82. });
  83. },
  84. // Punjabi notation for meridiems are quite fuzzy in practice. While there exists
  85. // a rigid notion of a 'Pahar' it is not used as rigidly in modern Punjabi.
  86. meridiemParse: /ਰਾਤ|ਸਵੇਰ|ਦੁਪਹਿਰ|ਸ਼ਾਮ/,
  87. meridiemHour: function (hour, meridiem) {
  88. if (hour === 12) {
  89. hour = 0;
  90. }
  91. if (meridiem === 'ਰਾਤ') {
  92. return hour < 4 ? hour : hour + 12;
  93. } else if (meridiem === 'ਸਵੇਰ') {
  94. return hour;
  95. } else if (meridiem === 'ਦੁਪਹਿਰ') {
  96. return hour >= 10 ? hour : hour + 12;
  97. } else if (meridiem === 'ਸ਼ਾਮ') {
  98. return hour + 12;
  99. }
  100. },
  101. meridiem: function (hour, minute, isLower) {
  102. if (hour < 4) {
  103. return 'ਰਾਤ';
  104. } else if (hour < 10) {
  105. return 'ਸਵੇਰ';
  106. } else if (hour < 17) {
  107. return 'ਦੁਪਹਿਰ';
  108. } else if (hour < 20) {
  109. return 'ਸ਼ਾਮ';
  110. } else {
  111. return 'ਰਾਤ';
  112. }
  113. },
  114. week: {
  115. dow: 0, // Sunday is the first day of the week.
  116. doy: 6, // The week that contains Jan 6th is the first week of the year.
  117. },
  118. });