pa-in.js 4.7 KB

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