Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

1534 rader
40 KiB

  1. ;(function(){
  2. /**
  3. * Require the module at `name`.
  4. *
  5. * @param {String} name
  6. * @return {Object} exports
  7. * @api public
  8. */
  9. function require(name) {
  10. var module = require.modules[name];
  11. if (!module) throw new Error('failed to require "' + name + '"');
  12. if (!('exports' in module) && typeof module.definition === 'function') {
  13. module.client = module.component = true;
  14. module.definition.call(this, module.exports = {}, module);
  15. delete module.definition;
  16. }
  17. return module.exports;
  18. }
  19. /**
  20. * Registered modules.
  21. */
  22. require.modules = {
  23. moment: { exports: moment }
  24. };
  25. /**
  26. * Register module at `name` with callback `definition`.
  27. *
  28. * @param {String} name
  29. * @param {Function} definition
  30. * @api private
  31. */
  32. require.register = function (name, definition) {
  33. require.modules[name] = {
  34. definition: definition
  35. };
  36. };
  37. /**
  38. * Define a module's exports immediately with `exports`.
  39. *
  40. * @param {String} name
  41. * @param {Generic} exports
  42. * @api private
  43. */
  44. require.define = function (name, exports) {
  45. require.modules[name] = {
  46. exports: exports
  47. };
  48. };
  49. require.register("jalaali-js", function (exports, module) {
  50. /*
  51. Expose functions.
  52. */
  53. module.exports =
  54. { toJalaali: toJalaali
  55. , toGregorian: toGregorian
  56. , isValidJalaaliDate: isValidJalaaliDate
  57. , isLeapJalaaliYear: isLeapJalaaliYear
  58. , jalaaliMonthLength: jalaaliMonthLength
  59. , jalCal: jalCal
  60. , j2d: j2d
  61. , d2j: d2j
  62. , g2d: g2d
  63. , d2g: d2g
  64. , jalaaliToDateObject: jalaaliToDateObject
  65. , jalaaliWeek: jalaaliWeek
  66. }
  67. /*
  68. Jalaali years starting the 33-year rule.
  69. */
  70. var breaks = [ -61, 9, 38, 199, 426, 686, 756, 818, 1111, 1181, 1210
  71. , 1635, 2060, 2097, 2192, 2262, 2324, 2394, 2456, 3178
  72. ]
  73. /*
  74. Converts a Gregorian date to Jalaali.
  75. */
  76. function toJalaali(gy, gm, gd) {
  77. if (Object.prototype.toString.call(gy) === '[object Date]') {
  78. gd = gy.getDate()
  79. gm = gy.getMonth() + 1
  80. gy = gy.getFullYear()
  81. }
  82. return d2j(g2d(gy, gm, gd))
  83. }
  84. /*
  85. Converts a Jalaali date to Gregorian.
  86. */
  87. function toGregorian(jy, jm, jd) {
  88. return d2g(j2d(jy, jm, jd))
  89. }
  90. /*
  91. Checks whether a Jalaali date is valid or not.
  92. */
  93. function isValidJalaaliDate(jy, jm, jd) {
  94. return jy >= -61 && jy <= 3177 &&
  95. jm >= 1 && jm <= 12 &&
  96. jd >= 1 && jd <= jalaaliMonthLength(jy, jm)
  97. }
  98. /*
  99. Is this a leap year or not?
  100. */
  101. function isLeapJalaaliYear(jy) {
  102. return jalCalLeap(jy) === 0
  103. }
  104. /*
  105. Number of days in a given month in a Jalaali year.
  106. */
  107. function jalaaliMonthLength(jy, jm) {
  108. if (jm <= 6) return 31
  109. if (jm <= 11) return 30
  110. if (isLeapJalaaliYear(jy)) return 30
  111. return 29
  112. }
  113. /*
  114. This function determines if the Jalaali (Persian) year is
  115. leap (366-day long) or is the common year (365 days)
  116. @param jy Jalaali calendar year (-61 to 3177)
  117. @returns number of years since the last leap year (0 to 4)
  118. */
  119. function jalCalLeap(jy) {
  120. var bl = breaks.length
  121. , jp = breaks[0]
  122. , jm
  123. , jump
  124. , leap
  125. , n
  126. , i
  127. if (jy < jp || jy >= breaks[bl - 1])
  128. throw new Error('Invalid Jalaali year ' + jy)
  129. for (i = 1; i < bl; i += 1) {
  130. jm = breaks[i]
  131. jump = jm - jp
  132. if (jy < jm)
  133. break
  134. jp = jm
  135. }
  136. n = jy - jp
  137. if (jump - n < 6)
  138. n = n - jump + div(jump + 4, 33) * 33
  139. leap = mod(mod(n + 1, 33) - 1, 4)
  140. if (leap === -1) {
  141. leap = 4
  142. }
  143. return leap
  144. }
  145. /*
  146. This function determines if the Jalaali (Persian) year is
  147. leap (366-day long) or is the common year (365 days), and
  148. finds the day in March (Gregorian calendar) of the first
  149. day of the Jalaali year (jy).
  150. @param jy Jalaali calendar year (-61 to 3177)
  151. @param withoutLeap when don't need leap (true or false) default is false
  152. @return
  153. leap: number of years since the last leap year (0 to 4)
  154. gy: Gregorian year of the beginning of Jalaali year
  155. march: the March day of Farvardin the 1st (1st day of jy)
  156. @see: http://www.astro.uni.torun.pl/~kb/Papers/EMP/PersianC-EMP.htm
  157. @see: http://www.fourmilab.ch/documents/calendar/
  158. */
  159. function jalCal(jy, withoutLeap) {
  160. var bl = breaks.length
  161. , gy = jy + 621
  162. , leapJ = -14
  163. , jp = breaks[0]
  164. , jm
  165. , jump
  166. , leap
  167. , leapG
  168. , march
  169. , n
  170. , i
  171. if (jy < jp || jy >= breaks[bl - 1])
  172. throw new Error('Invalid Jalaali year ' + jy)
  173. // Find the limiting years for the Jalaali year jy.
  174. for (i = 1; i < bl; i += 1) {
  175. jm = breaks[i]
  176. jump = jm - jp
  177. if (jy < jm)
  178. break
  179. leapJ = leapJ + div(jump, 33) * 8 + div(mod(jump, 33), 4)
  180. jp = jm
  181. }
  182. n = jy - jp
  183. // Find the number of leap years from AD 621 to the beginning
  184. // of the current Jalaali year in the Persian calendar.
  185. leapJ = leapJ + div(n, 33) * 8 + div(mod(n, 33) + 3, 4)
  186. if (mod(jump, 33) === 4 && jump - n === 4)
  187. leapJ += 1
  188. // And the same in the Gregorian calendar (until the year gy).
  189. leapG = div(gy, 4) - div((div(gy, 100) + 1) * 3, 4) - 150
  190. // Determine the Gregorian date of Farvardin the 1st.
  191. march = 20 + leapJ - leapG
  192. // return with gy and march when we don't need leap
  193. if (withoutLeap) return { gy: gy, march: march };
  194. // Find how many years have passed since the last leap year.
  195. if (jump - n < 6)
  196. n = n - jump + div(jump + 4, 33) * 33
  197. leap = mod(mod(n + 1, 33) - 1, 4)
  198. if (leap === -1) {
  199. leap = 4
  200. }
  201. return { leap: leap
  202. , gy: gy
  203. , march: march
  204. }
  205. }
  206. /*
  207. Converts a date of the Jalaali calendar to the Julian Day number.
  208. @param jy Jalaali year (1 to 3100)
  209. @param jm Jalaali month (1 to 12)
  210. @param jd Jalaali day (1 to 29/31)
  211. @return Julian Day number
  212. */
  213. function j2d(jy, jm, jd) {
  214. var r = jalCal(jy, true)
  215. return g2d(r.gy, 3, r.march) + (jm - 1) * 31 - div(jm, 7) * (jm - 7) + jd - 1
  216. }
  217. /*
  218. Converts the Julian Day number to a date in the Jalaali calendar.
  219. @param jdn Julian Day number
  220. @return
  221. jy: Jalaali year (1 to 3100)
  222. jm: Jalaali month (1 to 12)
  223. jd: Jalaali day (1 to 29/31)
  224. */
  225. function d2j(jdn) {
  226. var gy = d2g(jdn).gy // Calculate Gregorian year (gy).
  227. , jy = gy - 621
  228. , r = jalCal(jy, false)
  229. , jdn1f = g2d(gy, 3, r.march)
  230. , jd
  231. , jm
  232. , k
  233. // Find number of days that passed since 1 Farvardin.
  234. k = jdn - jdn1f
  235. if (k >= 0) {
  236. if (k <= 185) {
  237. // The first 6 months.
  238. jm = 1 + div(k, 31)
  239. jd = mod(k, 31) + 1
  240. return { jy: jy
  241. , jm: jm
  242. , jd: jd
  243. }
  244. } else {
  245. // The remaining months.
  246. k -= 186
  247. }
  248. } else {
  249. // Previous Jalaali year.
  250. jy -= 1
  251. k += 179
  252. if (r.leap === 1)
  253. k += 1
  254. }
  255. jm = 7 + div(k, 30)
  256. jd = mod(k, 30) + 1
  257. return { jy: jy
  258. , jm: jm
  259. , jd: jd
  260. }
  261. }
  262. /*
  263. Calculates the Julian Day number from Gregorian or Julian
  264. calendar dates. This integer number corresponds to the noon of
  265. the date (i.e. 12 hours of Universal Time).
  266. The procedure was tested to be good since 1 March, -100100 (of both
  267. calendars) up to a few million years into the future.
  268. @param gy Calendar year (years BC numbered 0, -1, -2, ...)
  269. @param gm Calendar month (1 to 12)
  270. @param gd Calendar day of the month (1 to 28/29/30/31)
  271. @return Julian Day number
  272. */
  273. function g2d(gy, gm, gd) {
  274. var d = div((gy + div(gm - 8, 6) + 100100) * 1461, 4)
  275. + div(153 * mod(gm + 9, 12) + 2, 5)
  276. + gd - 34840408
  277. d = d - div(div(gy + 100100 + div(gm - 8, 6), 100) * 3, 4) + 752
  278. return d
  279. }
  280. /*
  281. Calculates Gregorian and Julian calendar dates from the Julian Day number
  282. (jdn) for the period since jdn=-34839655 (i.e. the year -100100 of both
  283. calendars) to some millions years ahead of the present.
  284. @param jdn Julian Day number
  285. @return
  286. gy: Calendar year (years BC numbered 0, -1, -2, ...)
  287. gm: Calendar month (1 to 12)
  288. gd: Calendar day of the month M (1 to 28/29/30/31)
  289. */
  290. function d2g(jdn) {
  291. var j
  292. , i
  293. , gd
  294. , gm
  295. , gy
  296. j = 4 * jdn + 139361631
  297. j = j + div(div(4 * jdn + 183187720, 146097) * 3, 4) * 4 - 3908
  298. i = div(mod(j, 1461), 4) * 5 + 308
  299. gd = div(mod(i, 153), 5) + 1
  300. gm = mod(div(i, 153), 12) + 1
  301. gy = div(j, 1461) - 100100 + div(8 - gm, 6)
  302. return { gy: gy
  303. , gm: gm
  304. , gd: gd
  305. }
  306. }
  307. /**
  308. * Return Saturday and Friday day of current week(week start in Saturday)
  309. * @param {number} jy jalaali year
  310. * @param {number} jm jalaali month
  311. * @param {number} jd jalaali day
  312. * @returns Saturday and Friday of current week
  313. */
  314. function jalaaliWeek(jy, jm, jd) {
  315. var dayOfWeek = jalaaliToDateObject(jy, jm, jd).getDay();
  316. var startDayDifference = dayOfWeek == 6 ? 0 : -(dayOfWeek+1);
  317. var endDayDifference = 6+startDayDifference;
  318. return {
  319. saturday: d2j(j2d(jy, jm, jd+startDayDifference)),
  320. friday: d2j(j2d(jy, jm, jd+endDayDifference))
  321. }
  322. }
  323. /**
  324. * Convert Jalaali calendar dates to javascript Date object
  325. * @param {number} jy jalaali year
  326. * @param {number} jm jalaali month
  327. * @param {number} jd jalaali day
  328. * @param {number} [h] hours
  329. * @param {number} [m] minutes
  330. * @param {number} [s] seconds
  331. * @param {number} [ms] milliseconds
  332. * @returns Date object of the jalaali calendar dates
  333. */
  334. function jalaaliToDateObject(
  335. jy,
  336. jm,
  337. jd,
  338. h,
  339. m,
  340. s,
  341. ms
  342. ) {
  343. var gregorianCalenderDate = toGregorian(jy, jm, jd);
  344. return new Date(
  345. gregorianCalenderDate.gy,
  346. gregorianCalenderDate.gm - 1,
  347. gregorianCalenderDate.gd,
  348. h || 0,
  349. m || 0,
  350. s || 0,
  351. ms || 0
  352. );
  353. }
  354. /*
  355. Utility helper functions.
  356. */
  357. function div(a, b) {
  358. return ~~(a / b)
  359. }
  360. function mod(a, b) {
  361. return a - ~~(a / b) * b
  362. }
  363. })
  364. require.register("moment-jalaali", function (exports, module) {
  365. module.exports = jMoment
  366. var moment = require('moment/moment')
  367. , jalaali = require('jalaali-js')
  368. /************************************
  369. Constants
  370. ************************************/
  371. var formattingTokens = /(\[[^\[]*\])|(\\)?j(Mo|MM?M?M?|Do|DDDo|DD?D?D?|w[o|w]?|YYYYY|YYYY|YY|gg(ggg?)?|)|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/g
  372. , localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS?|LL?L?L?|l{1,4})/g
  373. , parseTokenOneOrTwoDigits = /\d\d?/
  374. , parseTokenOneToThreeDigits = /\d{1,3}/
  375. , parseTokenThreeDigits = /\d{3}/
  376. , parseTokenFourDigits = /\d{1,4}/
  377. , parseTokenSixDigits = /[+\-]?\d{1,6}/
  378. , parseTokenWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i
  379. , parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/i
  380. , parseTokenT = /T/i
  381. , parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/
  382. , symbolMap = {
  383. '1': '۱',
  384. '2': '۲',
  385. '3': '۳',
  386. '4': '۴',
  387. '5': '۵',
  388. '6': '۶',
  389. '7': '۷',
  390. '8': '۸',
  391. '9': '۹',
  392. '0': '۰'
  393. }
  394. , numberMap = {
  395. '۱': '1',
  396. '۲': '2',
  397. '۳': '3',
  398. '۴': '4',
  399. '۵': '5',
  400. '۶': '6',
  401. '۷': '7',
  402. '۸': '8',
  403. '۹': '9',
  404. '۰': '0'
  405. }
  406. , unitAliases =
  407. { jm: 'jmonth'
  408. , jmonths: 'jmonth'
  409. , jy: 'jyear'
  410. , jyears: 'jyear'
  411. }
  412. , formatFunctions = {}
  413. , ordinalizeTokens = 'DDD w M D'.split(' ')
  414. , paddedTokens = 'M D w'.split(' ')
  415. , formatTokenFunctions =
  416. { jM: function () {
  417. return this.jMonth() + 1
  418. }
  419. , jMMM: function (format) {
  420. return this.localeData().jMonthsShort(this, format)
  421. }
  422. , jMMMM: function (format) {
  423. return this.localeData().jMonths(this, format)
  424. }
  425. , jD: function () {
  426. return this.jDate()
  427. }
  428. , jDDD: function () {
  429. return this.jDayOfYear()
  430. }
  431. , jw: function () {
  432. return this.jWeek()
  433. }
  434. , jYY: function () {
  435. return leftZeroFill(this.jYear() % 100, 2)
  436. }
  437. , jYYYY: function () {
  438. return leftZeroFill(this.jYear(), 4)
  439. }
  440. , jYYYYY: function () {
  441. return leftZeroFill(this.jYear(), 5)
  442. }
  443. , jgg: function () {
  444. return leftZeroFill(this.jWeekYear() % 100, 2)
  445. }
  446. , jgggg: function () {
  447. return this.jWeekYear()
  448. }
  449. , jggggg: function () {
  450. return leftZeroFill(this.jWeekYear(), 5)
  451. }
  452. }
  453. function padToken(func, count) {
  454. return function (a) {
  455. return leftZeroFill(func.call(this, a), count)
  456. }
  457. }
  458. function ordinalizeToken(func, period) {
  459. return function (a) {
  460. return this.localeData().ordinal(func.call(this, a), period)
  461. }
  462. }
  463. (function () {
  464. var i
  465. while (ordinalizeTokens.length) {
  466. i = ordinalizeTokens.pop()
  467. formatTokenFunctions['j' + i + 'o'] = ordinalizeToken(formatTokenFunctions['j' + i], i)
  468. }
  469. while (paddedTokens.length) {
  470. i = paddedTokens.pop()
  471. formatTokenFunctions['j' + i + i] = padToken(formatTokenFunctions['j' + i], 2)
  472. }
  473. formatTokenFunctions.jDDDD = padToken(formatTokenFunctions.jDDD, 3)
  474. }())
  475. /************************************
  476. Helpers
  477. ************************************/
  478. function extend(a, b) {
  479. var key
  480. for (key in b)
  481. if (b.hasOwnProperty(key))
  482. a[key] = b[key]
  483. return a
  484. }
  485. function leftZeroFill(number, targetLength) {
  486. var output = number + ''
  487. while (output.length < targetLength)
  488. output = '0' + output
  489. return output
  490. }
  491. function isArray(input) {
  492. return Object.prototype.toString.call(input) === '[object Array]'
  493. }
  494. // function compareArrays(array1, array2) {
  495. // var len = Math.min(array1.length, array2.length)
  496. // , lengthDiff = Math.abs(array1.length - array2.length)
  497. // , diffs = 0
  498. // , i
  499. // for (i = 0; i < len; i += 1)
  500. // if (~~array1[i] !== ~~array2[i])
  501. // diffs += 1
  502. // return diffs + lengthDiff
  503. // }
  504. function normalizeUnits(units) {
  505. if (units) {
  506. var lowered = units.toLowerCase()
  507. units = unitAliases[lowered] || lowered
  508. }
  509. return units
  510. }
  511. function setDate(m, year, month, date) {
  512. var d = m._d
  513. if (isNaN(year)) {
  514. m._isValid = false
  515. }
  516. if (m._isUTC) {
  517. /*eslint-disable new-cap*/
  518. m._d = new Date(Date.UTC(year, month, date,
  519. d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()))
  520. /*eslint-enable new-cap*/
  521. } else {
  522. m._d = new Date(year, month, date,
  523. d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds())
  524. }
  525. }
  526. function objectCreate(parent) {
  527. function F() {}
  528. F.prototype = parent
  529. return new F()
  530. }
  531. function getPrototypeOf(object) {
  532. if (Object.getPrototypeOf)
  533. return Object.getPrototypeOf(object)
  534. else if (''.__proto__)
  535. return object.__proto__
  536. else
  537. return object.constructor.prototype
  538. }
  539. /************************************
  540. Languages
  541. ************************************/
  542. extend(getPrototypeOf(moment.localeData()),
  543. { _jMonths: [ 'Farvardin'
  544. , 'Ordibehesht'
  545. , 'Khordaad'
  546. , 'Tir'
  547. , 'Amordaad'
  548. , 'Shahrivar'
  549. , 'Mehr'
  550. , 'Aabaan'
  551. , 'Aazar'
  552. , 'Dey'
  553. , 'Bahman'
  554. , 'Esfand'
  555. ]
  556. , jMonths: function (m) {
  557. return this._jMonths[m.jMonth()]
  558. }
  559. , _jMonthsShort: [ 'Far'
  560. , 'Ord'
  561. , 'Kho'
  562. , 'Tir'
  563. , 'Amo'
  564. , 'Sha'
  565. , 'Meh'
  566. , 'Aab'
  567. , 'Aaz'
  568. , 'Dey'
  569. , 'Bah'
  570. , 'Esf'
  571. ]
  572. , jMonthsShort: function (m) {
  573. return this._jMonthsShort[m.jMonth()]
  574. }
  575. , jMonthsParse: function (monthName) {
  576. var i
  577. , mom
  578. , regex
  579. if (!this._jMonthsParse)
  580. this._jMonthsParse = []
  581. for (i = 0; i < 12; i += 1) {
  582. // Make the regex if we don't have it already.
  583. if (!this._jMonthsParse[i]) {
  584. mom = jMoment([2000, (2 + i) % 12, 25])
  585. regex = '^' + this.jMonths(mom, '') + '|^' + this.jMonthsShort(mom, '')
  586. this._jMonthsParse[i] = new RegExp(regex.replace('.', ''), 'i')
  587. }
  588. // Test the regex.
  589. if (this._jMonthsParse[i].test(monthName))
  590. return i
  591. }
  592. }
  593. }
  594. )
  595. /************************************
  596. Formatting
  597. ************************************/
  598. function makeFormatFunction(format) {
  599. var array = format.match(formattingTokens)
  600. , length = array.length
  601. , i
  602. for (i = 0; i < length; i += 1)
  603. if (formatTokenFunctions[array[i]])
  604. array[i] = formatTokenFunctions[array[i]]
  605. return function (mom) {
  606. var output = ''
  607. for (i = 0; i < length; i += 1)
  608. output += array[i] instanceof Function ? '[' + array[i].call(mom, format) + ']' : array[i]
  609. return output
  610. }
  611. }
  612. /************************************
  613. Parsing
  614. ************************************/
  615. function getParseRegexForToken(token, config) {
  616. switch (token) {
  617. case 'jDDDD':
  618. return parseTokenThreeDigits
  619. case 'jYYYY':
  620. return parseTokenFourDigits
  621. case 'jYYYYY':
  622. return parseTokenSixDigits
  623. case 'jDDD':
  624. return parseTokenOneToThreeDigits
  625. case 'jMMM':
  626. case 'jMMMM':
  627. return parseTokenWord
  628. case 'jMM':
  629. case 'jDD':
  630. case 'jYY':
  631. case 'jM':
  632. case 'jD':
  633. return parseTokenOneOrTwoDigits
  634. case 'DDDD':
  635. return parseTokenThreeDigits
  636. case 'YYYY':
  637. return parseTokenFourDigits
  638. case 'YYYYY':
  639. return parseTokenSixDigits
  640. case 'S':
  641. case 'SS':
  642. case 'SSS':
  643. case 'DDD':
  644. return parseTokenOneToThreeDigits
  645. case 'MMM':
  646. case 'MMMM':
  647. case 'dd':
  648. case 'ddd':
  649. case 'dddd':
  650. return parseTokenWord
  651. case 'a':
  652. case 'A':
  653. return moment.localeData(config._l)._meridiemParse
  654. case 'X':
  655. return parseTokenTimestampMs
  656. case 'Z':
  657. case 'ZZ':
  658. return parseTokenTimezone
  659. case 'T':
  660. return parseTokenT
  661. case 'MM':
  662. case 'DD':
  663. case 'YY':
  664. case 'HH':
  665. case 'hh':
  666. case 'mm':
  667. case 'ss':
  668. case 'M':
  669. case 'D':
  670. case 'd':
  671. case 'H':
  672. case 'h':
  673. case 'm':
  674. case 's':
  675. return parseTokenOneOrTwoDigits
  676. default:
  677. return new RegExp(token.replace('\\', ''))
  678. }
  679. }
  680. function addTimeToArrayFromToken(token, input, config) {
  681. var a
  682. , datePartArray = config._a
  683. switch (token) {
  684. case 'jM':
  685. case 'jMM':
  686. datePartArray[1] = input == null ? 0 : ~~input - 1
  687. break
  688. case 'jMMM':
  689. case 'jMMMM':
  690. a = moment.localeData(config._l).jMonthsParse(input)
  691. if (a != null)
  692. datePartArray[1] = a
  693. else
  694. config._isValid = false
  695. break
  696. case 'jD':
  697. case 'jDD':
  698. case 'jDDD':
  699. case 'jDDDD':
  700. if (input != null)
  701. datePartArray[2] = ~~input
  702. break
  703. case 'jYY':
  704. datePartArray[0] = ~~input + (~~input > 47 ? 1300 : 1400)
  705. break
  706. case 'jYYYY':
  707. case 'jYYYYY':
  708. datePartArray[0] = ~~input
  709. }
  710. if (input == null)
  711. config._isValid = false
  712. }
  713. function dateFromArray(config) {
  714. var g
  715. , j
  716. , jy = config._a[0]
  717. , jm = config._a[1]
  718. , jd = config._a[2]
  719. if ((jy == null) && (jm == null) && (jd == null))
  720. return [0, 0, 1]
  721. jy = jy != null ? jy : 0
  722. jm = jm != null ? jm : 0
  723. jd = jd != null ? jd : 1
  724. if (jd < 1 || jd > jMoment.jDaysInMonth(jy, jm) || jm < 0 || jm > 11)
  725. config._isValid = false
  726. g = toGregorian(jy, jm, jd)
  727. j = toJalaali(g.gy, g.gm, g.gd)
  728. if (isNaN(g.gy))
  729. config._isValid = false
  730. config._jDiff = 0
  731. if (~~j.jy !== jy)
  732. config._jDiff += 1
  733. if (~~j.jm !== jm)
  734. config._jDiff += 1
  735. if (~~j.jd !== jd)
  736. config._jDiff += 1
  737. return [g.gy, g.gm, g.gd]
  738. }
  739. function makeDateFromStringAndFormat(config) {
  740. var tokens = config._f.match(formattingTokens)
  741. , string = config._i + ''
  742. , len = tokens.length
  743. , i
  744. , token
  745. , parsedInput
  746. config._a = []
  747. for (i = 0; i < len; i += 1) {
  748. token = tokens[i]
  749. parsedInput = (getParseRegexForToken(token, config).exec(string) || [])[0]
  750. if (parsedInput)
  751. string = string.slice(string.indexOf(parsedInput) + parsedInput.length)
  752. if (formatTokenFunctions[token])
  753. addTimeToArrayFromToken(token, parsedInput, config)
  754. }
  755. if (string)
  756. config._il = string
  757. return dateFromArray(config)
  758. }
  759. function makeDateFromStringAndArray(config, utc) {
  760. var len = config._f.length
  761. , i
  762. , format
  763. , tempMoment
  764. , bestMoment
  765. , currentScore
  766. , scoreToBeat
  767. if (len === 0) {
  768. return makeMoment(new Date(NaN))
  769. }
  770. for (i = 0; i < len; i += 1) {
  771. format = config._f[i]
  772. currentScore = 0
  773. tempMoment = makeMoment(config._i, format, config._l, config._strict, utc)
  774. if (!tempMoment.isValid()) continue
  775. // currentScore = compareArrays(tempMoment._a, tempMoment.toArray())
  776. currentScore += tempMoment._jDiff
  777. if (tempMoment._il)
  778. currentScore += tempMoment._il.length
  779. if (scoreToBeat == null || currentScore < scoreToBeat) {
  780. scoreToBeat = currentScore
  781. bestMoment = tempMoment
  782. }
  783. }
  784. return bestMoment
  785. }
  786. function removeParsedTokens(config) {
  787. var string = config._i + ''
  788. , input = ''
  789. , format = ''
  790. , array = config._f.match(formattingTokens)
  791. , len = array.length
  792. , i
  793. , match
  794. , parsed
  795. for (i = 0; i < len; i += 1) {
  796. match = array[i]
  797. parsed = (getParseRegexForToken(match, config).exec(string) || [])[0]
  798. if (parsed)
  799. string = string.slice(string.indexOf(parsed) + parsed.length)
  800. if (!(formatTokenFunctions[match] instanceof Function)) {
  801. format += match
  802. if (parsed)
  803. input += parsed
  804. }
  805. }
  806. config._i = input
  807. config._f = format
  808. }
  809. /************************************
  810. Week of Year
  811. ************************************/
  812. function jWeekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
  813. var end = firstDayOfWeekOfYear - firstDayOfWeek
  814. , daysToDayOfWeek = firstDayOfWeekOfYear - mom.day()
  815. , adjustedMoment
  816. if (daysToDayOfWeek > end) {
  817. daysToDayOfWeek -= 7
  818. }
  819. if (daysToDayOfWeek < end - 7) {
  820. daysToDayOfWeek += 7
  821. }
  822. adjustedMoment = jMoment(mom).add(daysToDayOfWeek, 'd')
  823. return { week: Math.ceil(adjustedMoment.jDayOfYear() / 7)
  824. , year: adjustedMoment.jYear()
  825. }
  826. }
  827. /************************************
  828. Top Level Functions
  829. ************************************/
  830. var maxTimestamp = 57724432199999
  831. function makeMoment(input, format, lang, strict, utc) {
  832. if (typeof lang === 'boolean') {
  833. strict = lang
  834. lang = undefined
  835. }
  836. if (format && typeof format === 'string')
  837. format = fixFormat(format, moment)
  838. var config =
  839. { _i: input
  840. , _f: format
  841. , _l: lang
  842. , _strict: strict
  843. , _isUTC: utc
  844. }
  845. , date
  846. , m
  847. , jm
  848. , origInput = input
  849. , origFormat = format
  850. if (format) {
  851. if (isArray(format)) {
  852. return makeDateFromStringAndArray(config, utc)
  853. } else {
  854. date = makeDateFromStringAndFormat(config)
  855. removeParsedTokens(config)
  856. format = 'YYYY-MM-DD-' + config._f
  857. input = leftZeroFill(date[0], 4) + '-'
  858. + leftZeroFill(date[1] + 1, 2) + '-'
  859. + leftZeroFill(date[2], 2) + '-'
  860. + config._i
  861. }
  862. }
  863. if (utc)
  864. m = moment.utc(input, format, lang, strict)
  865. else
  866. m = moment(input, format, lang, strict)
  867. if (config._isValid === false)
  868. m._isValid = false
  869. m._jDiff = config._jDiff || 0
  870. jm = objectCreate(jMoment.fn)
  871. extend(jm, m)
  872. if (strict && format && jm.isValid()) {
  873. jm._isValid = jm.format(origFormat) === origInput
  874. }
  875. if (m._d.getTime() > maxTimestamp) {
  876. jm._isValid = false
  877. }
  878. return jm
  879. }
  880. function jMoment(input, format, lang, strict) {
  881. return makeMoment(input, format, lang, strict, false)
  882. }
  883. extend(jMoment, moment)
  884. jMoment.fn = objectCreate(moment.fn)
  885. jMoment.utc = function (input, format, lang, strict) {
  886. return makeMoment(input, format, lang, strict, true)
  887. }
  888. jMoment.unix = function (input) {
  889. return makeMoment(input * 1000)
  890. }
  891. /************************************
  892. jMoment Prototype
  893. ************************************/
  894. function fixFormat(format, _moment) {
  895. var i = 5
  896. var replace = function (input) {
  897. return _moment.localeData().longDateFormat(input) || input
  898. }
  899. while (i > 0 && localFormattingTokens.test(format)) {
  900. i -= 1
  901. format = format.replace(localFormattingTokens, replace)
  902. }
  903. return format
  904. }
  905. jMoment.fn.format = function (format) {
  906. if (format) {
  907. format = fixFormat(format, this)
  908. if (!formatFunctions[format]) {
  909. formatFunctions[format] = makeFormatFunction(format)
  910. }
  911. format = formatFunctions[format](this)
  912. }
  913. return moment.fn.format.call(this, format)
  914. }
  915. jMoment.fn.jYear = function (input) {
  916. var lastDay
  917. , j
  918. , g
  919. if (typeof input === 'number') {
  920. j = toJalaali(this.year(), this.month(), this.date())
  921. lastDay = Math.min(j.jd, jMoment.jDaysInMonth(input, j.jm))
  922. g = toGregorian(input, j.jm, lastDay)
  923. setDate(this, g.gy, g.gm, g.gd)
  924. moment.updateOffset(this)
  925. return this
  926. } else {
  927. return toJalaali(this.year(), this.month(), this.date()).jy
  928. }
  929. }
  930. jMoment.fn.jMonth = function (input) {
  931. var lastDay
  932. , j
  933. , g
  934. if (input != null) {
  935. if (typeof input === 'string') {
  936. input = this.localeData().jMonthsParse(input)
  937. if (typeof input !== 'number')
  938. return this
  939. }
  940. j = toJalaali(this.year(), this.month(), this.date())
  941. lastDay = Math.min(j.jd, jMoment.jDaysInMonth(j.jy, input))
  942. this.jYear(j.jy + div(input, 12))
  943. input = mod(input, 12)
  944. if (input < 0) {
  945. input += 12
  946. this.jYear(this.jYear() - 1)
  947. }
  948. g = toGregorian(this.jYear(), input, lastDay)
  949. setDate(this, g.gy, g.gm, g.gd)
  950. moment.updateOffset(this)
  951. return this
  952. } else {
  953. return toJalaali(this.year(), this.month(), this.date()).jm
  954. }
  955. }
  956. jMoment.fn.jDate = function (input) {
  957. var j
  958. , g
  959. if (typeof input === 'number') {
  960. j = toJalaali(this.year(), this.month(), this.date())
  961. g = toGregorian(j.jy, j.jm, input)
  962. setDate(this, g.gy, g.gm, g.gd)
  963. moment.updateOffset(this)
  964. return this
  965. } else {
  966. return toJalaali(this.year(), this.month(), this.date()).jd
  967. }
  968. }
  969. jMoment.fn.jDayOfYear = function (input) {
  970. var dayOfYear = Math.round((jMoment(this).startOf('day') - jMoment(this).startOf('jYear')) / 864e5) + 1
  971. return input == null ? dayOfYear : this.add(input - dayOfYear, 'd')
  972. }
  973. jMoment.fn.jWeek = function (input) {
  974. var week = jWeekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).week
  975. return input == null ? week : this.add((input - week) * 7, 'd')
  976. }
  977. jMoment.fn.jWeekYear = function (input) {
  978. var year = jWeekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year
  979. return input == null ? year : this.add(input - year, 'y')
  980. }
  981. jMoment.fn.add = function (val, units) {
  982. var temp
  983. if (units !== null && !isNaN(+units)) {
  984. temp = val
  985. val = units
  986. units = temp
  987. }
  988. units = normalizeUnits(units)
  989. if (units === 'jyear') {
  990. this.jYear(this.jYear() + val)
  991. } else if (units === 'jmonth') {
  992. this.jMonth(this.jMonth() + val)
  993. } else {
  994. moment.fn.add.call(this, val, units)
  995. if (isNaN(this.jYear())) {
  996. this._isValid = false
  997. }
  998. }
  999. return this
  1000. }
  1001. jMoment.fn.subtract = function (val, units) {
  1002. var temp
  1003. if (units !== null && !isNaN(+units)) {
  1004. temp = val
  1005. val = units
  1006. units = temp
  1007. }
  1008. units = normalizeUnits(units)
  1009. if (units === 'jyear') {
  1010. this.jYear(this.jYear() - val)
  1011. } else if (units === 'jmonth') {
  1012. this.jMonth(this.jMonth() - val)
  1013. } else {
  1014. moment.fn.subtract.call(this, val, units)
  1015. }
  1016. return this
  1017. }
  1018. jMoment.fn.startOf = function (units) {
  1019. units = normalizeUnits(units)
  1020. if (units === 'jyear' || units === 'jmonth') {
  1021. if (units === 'jyear') {
  1022. this.jMonth(0)
  1023. }
  1024. this.jDate(1)
  1025. this.hours(0)
  1026. this.minutes(0)
  1027. this.seconds(0)
  1028. this.milliseconds(0)
  1029. return this
  1030. } else {
  1031. return moment.fn.startOf.call(this, units)
  1032. }
  1033. }
  1034. jMoment.fn.endOf = function (units) {
  1035. units = normalizeUnits(units)
  1036. if (units === undefined || units === 'milisecond') {
  1037. return this
  1038. }
  1039. return this.startOf(units).add(1, (units === 'isoweek' ? 'week' : units)).subtract(1, 'ms')
  1040. }
  1041. jMoment.fn.isSame = function (other, units) {
  1042. units = normalizeUnits(units)
  1043. if (units === 'jyear' || units === 'jmonth') {
  1044. return moment.fn.isSame.call(this.startOf(units), other.startOf(units))
  1045. }
  1046. return moment.fn.isSame.call(this, other, units)
  1047. }
  1048. jMoment.fn.clone = function () {
  1049. return jMoment(this)
  1050. }
  1051. jMoment.fn.jYears = jMoment.fn.jYear
  1052. jMoment.fn.jMonths = jMoment.fn.jMonth
  1053. jMoment.fn.jDates = jMoment.fn.jDate
  1054. jMoment.fn.jWeeks = jMoment.fn.jWeek
  1055. /************************************
  1056. jMoment Statics
  1057. ************************************/
  1058. jMoment.jDaysInMonth = function (year, month) {
  1059. year += div(month, 12)
  1060. month = mod(month, 12)
  1061. if (month < 0) {
  1062. month += 12
  1063. year -= 1
  1064. }
  1065. if (month < 6) {
  1066. return 31
  1067. } else if (month < 11) {
  1068. return 30
  1069. } else if (jMoment.jIsLeapYear(year)) {
  1070. return 30
  1071. } else {
  1072. return 29
  1073. }
  1074. }
  1075. jMoment.jIsLeapYear = jalaali.isLeapJalaaliYear
  1076. jMoment.loadPersian = function (args) {
  1077. var usePersianDigits = args !== undefined && args.hasOwnProperty('usePersianDigits') ? args.usePersianDigits : false
  1078. var dialect = args !== undefined && args.hasOwnProperty('dialect') ? args.dialect : 'persian'
  1079. moment.locale('fa')
  1080. moment.updateLocale('fa'
  1081. , { months: ('ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر').split('_')
  1082. , monthsShort: ('ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر').split('_')
  1083. , weekdays:
  1084. {
  1085. 'persian': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_آدینه_شنبه').split('_'),
  1086. 'persian-modern': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه').split('_')
  1087. }[dialect]
  1088. , weekdaysShort:
  1089. {
  1090. 'persian': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_آدینه_شنبه').split('_'),
  1091. 'persian-modern': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه').split('_')
  1092. }[dialect]
  1093. , weekdaysMin:
  1094. {
  1095. 'persian': 'ی_د_س_چ_پ_آ_ش'.split('_'),
  1096. 'persian-modern': 'ی_د_س_چ_پ_ج_ش'.split('_')
  1097. }[dialect]
  1098. , longDateFormat:
  1099. { LT: 'HH:mm'
  1100. , L: 'jYYYY/jMM/jDD'
  1101. , LL: 'jD jMMMM jYYYY'
  1102. , LLL: 'jD jMMMM jYYYY LT'
  1103. , LLLL: 'dddd، jD jMMMM jYYYY LT'
  1104. }
  1105. , calendar:
  1106. { sameDay: '[امروز ساعت] LT'
  1107. , nextDay: '[فردا ساعت] LT'
  1108. , nextWeek: 'dddd [ساعت] LT'
  1109. , lastDay: '[دیروز ساعت] LT'
  1110. , lastWeek: 'dddd [ی پیش ساعت] LT'
  1111. , sameElse: 'L'
  1112. }
  1113. , relativeTime:
  1114. { future: 'در %s'
  1115. , past: '%s پیش'
  1116. , s: 'چند ثانیه'
  1117. , m: '1 دقیقه'
  1118. , mm: '%d دقیقه'
  1119. , h: '1 ساعت'
  1120. , hh: '%d ساعت'
  1121. , d: '1 روز'
  1122. , dd: '%d روز'
  1123. , M: '1 ماه'
  1124. , MM: '%d ماه'
  1125. , y: '1 سال'
  1126. , yy: '%d سال'
  1127. }
  1128. , preparse: function (string) {
  1129. if (usePersianDigits) {
  1130. return string.replace(/[۰-۹]/g, function (match) {
  1131. return numberMap[match]
  1132. }).replace(/،/g, ',')
  1133. }
  1134. return string
  1135. }
  1136. , postformat: function (string) {
  1137. if (usePersianDigits) {
  1138. return string.replace(/\d/g, function (match) {
  1139. return symbolMap[match]
  1140. }).replace(/,/g, '،')
  1141. }
  1142. return string
  1143. }
  1144. , ordinal: '%dم'
  1145. , week:
  1146. { dow: 6 // Saturday is the first day of the week.
  1147. , doy: 12 // The week that contains Jan 1st is the first week of the year.
  1148. }
  1149. , meridiem: function (hour) {
  1150. return hour < 12 ? 'ق.ظ' : 'ب.ظ'
  1151. }
  1152. , jMonths:
  1153. {
  1154. 'persian': ('فروردین_اردیبهشت_خرداد_تیر_امرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند').split('_'),
  1155. 'persian-modern': ('فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند').split('_')
  1156. }[dialect]
  1157. , jMonthsShort:
  1158. {
  1159. 'persian': 'فرو_ارد_خرد_تیر_امر_شهر_مهر_آبا_آذر_دی_بهم_اسف'.split('_'),
  1160. 'persian-modern': 'فرو_ارد_خرد_تیر_مرد_شهر_مهر_آبا_آذر_دی_بهم_اسف'.split('_')
  1161. }[dialect]
  1162. }
  1163. )
  1164. }
  1165. jMoment.loadPersian_dari = function (args) {
  1166. var usePersianDigits = args !== undefined && args.hasOwnProperty('usePersianDigits') ? args.usePersianDigits : false
  1167. var dialect = args !== undefined && args.hasOwnProperty('dialect') ? args.dialect : 'persian-dari'
  1168. moment.locale('fa-af')
  1169. moment.updateLocale('fa-af'
  1170. , { months: ('جنوری_فبروری_مارچ_اپریل_می_جون_جولای_آگست_سپتمبر_اکتوبر_نومبر_دیسمبر').split('_')
  1171. , monthsShort: ('جنوری_فبروری_مارچ_اپریل_می_جون_جولای_آگست_سپتمبر_اکتوبر_نومبر_دیسمبر').split('_')
  1172. , weekdays:
  1173. {
  1174. 'persian': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_آدینه_شنبه').split('_'),
  1175. 'persian-modern': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه').split('_')
  1176. }[dialect]
  1177. , weekdaysShort:
  1178. {
  1179. 'persian': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_آدینه_شنبه').split('_'),
  1180. 'persian-modern': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه').split('_')
  1181. }[dialect]
  1182. , weekdaysMin:
  1183. {
  1184. 'persian': 'ی_د_س_چ_پ_آ_ش'.split('_'),
  1185. 'persian-modern': 'ی_د_س_چ_پ_ج_ش'.split('_')
  1186. }[dialect]
  1187. , longDateFormat:
  1188. { LT: 'HH:mm'
  1189. , L: 'jYYYY/jMM/jDD'
  1190. , LL: 'jD jMMMM jYYYY'
  1191. , LLL: 'jD jMMMM jYYYY LT'
  1192. , LLLL: 'dddd، jD jMMMM jYYYY LT'
  1193. }
  1194. , calendar:
  1195. { sameDay: '[امروز ساعت] LT'
  1196. , nextDay: '[فردا ساعت] LT'
  1197. , nextWeek: 'dddd [ساعت] LT'
  1198. , lastDay: '[دیروز ساعت] LT'
  1199. , lastWeek: 'dddd [ی پیش ساعت] LT'
  1200. , sameElse: 'L'
  1201. }
  1202. , relativeTime:
  1203. { future: 'در %s'
  1204. , past: '%s پیش'
  1205. , s: 'چند ثانیه'
  1206. , m: '1 دقیقه'
  1207. , mm: '%d دقیقه'
  1208. , h: '1 ساعت'
  1209. , hh: '%d ساعت'
  1210. , d: '1 روز'
  1211. , dd: '%d روز'
  1212. , M: '1 ماه'
  1213. , MM: '%d ماه'
  1214. , y: '1 سال'
  1215. , yy: '%d سال'
  1216. }
  1217. , preparse: function (string) {
  1218. if (usePersianDigits) {
  1219. return string.replace(/[۰-۹]/g, function (match) {
  1220. return numberMap[match]
  1221. }).replace(/،/g, ',')
  1222. }
  1223. return string
  1224. }
  1225. , postformat: function (string) {
  1226. if (usePersianDigits) {
  1227. return string.replace(/\d/g, function (match) {
  1228. return symbolMap[match]
  1229. }).replace(/,/g, '،')
  1230. }
  1231. return string
  1232. }
  1233. , ordinal: '%dم'
  1234. , week:
  1235. { dow: 6 // Saturday is the first day of the week.
  1236. , doy: 12 // The week that contains Jan 1st is the first week of the year.
  1237. }
  1238. , meridiem: function (hour) {
  1239. return hour < 12 ? 'ق.ظ' : 'ب.ظ'
  1240. }
  1241. , jMonths:
  1242. {
  1243. 'persian-dari': ('حمل_ثور_جوزا_سرطان_اسد_سنبله_میزان_عقرب_قوس_جدی_دلو_حوت').split('_'),
  1244. 'persian-modern-dari': ('حمل_ثور_جوزا_سرطان_اسد_سنبله_میزان_عقرب_قوس_جدی_دلو_حوت').split('_')
  1245. }[dialect]
  1246. , jMonthsShort:
  1247. {
  1248. 'persian-dari': 'حمل_ثور_جوزا_سرط_اسد_سنب_میز_عقر_قوس_جدی_دلو_حوت'.split('_'),
  1249. 'persian-modern-dari': 'حمل_ثور_جوزا_سرط_اسد_سنب_میز_عقر_قوس_جدی_دلو_حوت'.split('_')
  1250. }[dialect]
  1251. }
  1252. )
  1253. }
  1254. jMoment.loadPashto = function (args) {
  1255. var usePersianDigits = args !== undefined && args.hasOwnProperty('usePersianDigits') ? args.usePersianDigits : false
  1256. var dialect = args !== undefined && args.hasOwnProperty('dialect') ? args.dialect : 'pashto'
  1257. moment.locale('ps-af')
  1258. moment.updateLocale('ps-af'
  1259. , { months: ('جنوری_فبروری_مارچ_اپریل_می_جون_جولای_آگست_سپتمبر_اکتوبر_نومبر_دیسمبر').split('_')
  1260. , monthsShort: ('جنوری_فبروری_مارچ_اپریل_می_جون_جولای_آگست_سپتمبر_اکتوبر_نومبر_دیسمبر').split('_')
  1261. , weekdays:
  1262. {
  1263. 'pashto': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_آدینه_شنبه').split('_'),
  1264. 'pashto-modern': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه').split('_')
  1265. }[dialect]
  1266. , weekdaysShort:
  1267. {
  1268. 'pashto': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_آدینه_شنبه').split('_'),
  1269. 'pashto-modern': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه').split('_')
  1270. }[dialect]
  1271. , weekdaysMin:
  1272. {
  1273. 'pashto': 'ی_د_س_چ_پ_آ_ش'.split('_'),
  1274. 'pashto-modern': 'ی_د_س_چ_پ_ج_ش'.split('_')
  1275. }[dialect]
  1276. , longDateFormat:
  1277. { LT: 'HH:mm'
  1278. , L: 'jYYYY/jMM/jDD'
  1279. , LL: 'jD jMMMM jYYYY'
  1280. , LLL: 'jD jMMMM jYYYY LT'
  1281. , LLLL: 'dddd، jD jMMMM jYYYY LT'
  1282. }
  1283. , calendar:
  1284. { sameDay: '[امروز ساعت] LT'
  1285. , nextDay: '[فردا ساعت] LT'
  1286. , nextWeek: 'dddd [ساعت] LT'
  1287. , lastDay: '[دیروز ساعت] LT'
  1288. , lastWeek: 'dddd [ی پیش ساعت] LT'
  1289. , sameElse: 'L'
  1290. }
  1291. , relativeTime:
  1292. { future: 'در %s'
  1293. , past: '%s پیش'
  1294. , s: 'چند ثانیه'
  1295. , m: '1 دقیقه'
  1296. , mm: '%d دقیقه'
  1297. , h: '1 ساعت'
  1298. , hh: '%d ساعت'
  1299. , d: '1 روز'
  1300. , dd: '%d روز'
  1301. , M: '1 ماه'
  1302. , MM: '%d ماه'
  1303. , y: '1 سال'
  1304. , yy: '%d سال'
  1305. }
  1306. , preparse: function (string) {
  1307. if (usePersianDigits) {
  1308. return string.replace(/[۰-۹]/g, function (match) {
  1309. return numberMap[match]
  1310. }).replace(/،/g, ',')
  1311. }
  1312. return string
  1313. }
  1314. , postformat: function (string) {
  1315. if (usePersianDigits) {
  1316. return string.replace(/\d/g, function (match) {
  1317. return symbolMap[match]
  1318. }).replace(/,/g, '،')
  1319. }
  1320. return string
  1321. }
  1322. , ordinal: '%dم'
  1323. , week:
  1324. { dow: 6 // Saturday is the first day of the week.
  1325. , doy: 12 // The week that contains Jan 1st is the first week of the year.
  1326. }
  1327. , meridiem: function (hour) {
  1328. return hour < 12 ? 'ق.ظ' : 'ب.ظ'
  1329. }
  1330. , jMonths:
  1331. {
  1332. 'pashto': ('وری_غویی_غبرګولی_چنګاښ_زمری_وږی_تله_لړم_لیندی_مرغومی_سلواغه_کب').split('_'),
  1333. 'pashto-modern': ('وری_غویی_غبرګولی_چنګاښ_زمری_وږی_تله_لړم_لیندی_مرغومی_سلواغه_کب').split('_')
  1334. }[dialect]
  1335. , jMonthsShort:
  1336. {
  1337. 'pashto': 'وری_غوی_غبر_چنګ_زمر_وږی_لړم_لین_مرغ_سلو_کب'.split('_'),
  1338. 'pashto-modern': 'وری_غوی_غبر_چنګ_زمر_وږی_لړم_لین_مرغ_سلو_کب'.split('_')
  1339. }[dialect]
  1340. }
  1341. )
  1342. }
  1343. jMoment.jConvert = { toJalaali: toJalaali
  1344. , toGregorian: toGregorian
  1345. }
  1346. /************************************
  1347. Jalaali Conversion
  1348. ************************************/
  1349. function toJalaali(gy, gm, gd) {
  1350. try {
  1351. var j = jalaali.toJalaali(gy, gm + 1, gd)
  1352. j.jm -= 1
  1353. return j
  1354. } catch (e) {
  1355. return {
  1356. jy: NaN
  1357. , jm: NaN
  1358. , jd: NaN
  1359. }
  1360. }
  1361. }
  1362. function toGregorian(jy, jm, jd) {
  1363. try {
  1364. var g = jalaali.toGregorian(jy, jm + 1, jd)
  1365. g.gm -= 1
  1366. return g
  1367. } catch (e) {
  1368. return {
  1369. gy: NaN
  1370. , gm: NaN
  1371. , gd: NaN
  1372. }
  1373. }
  1374. }
  1375. /*
  1376. Utility helper functions.
  1377. */
  1378. function div(a, b) {
  1379. return ~~(a / b)
  1380. }
  1381. function mod(a, b) {
  1382. return a - ~~(a / b) * b
  1383. }
  1384. });
  1385. if (typeof exports == "object") {
  1386. module.exports = require("moment-jalaali");
  1387. } else if (typeof define == "function" && define.amd) {
  1388. define([], function(){ return require("moment-jalaali"); });
  1389. } else {
  1390. this["moment"] = require("moment-jalaali");
  1391. }
  1392. })();