@internationalized/date 3.6.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/BuddhistCalendar.main.js.map +1 -1
  2. package/dist/BuddhistCalendar.module.js.map +1 -1
  3. package/dist/CalendarDate.main.js.map +1 -1
  4. package/dist/CalendarDate.module.js.map +1 -1
  5. package/dist/EthiopicCalendar.main.js.map +1 -1
  6. package/dist/EthiopicCalendar.module.js.map +1 -1
  7. package/dist/GregorianCalendar.main.js.map +1 -1
  8. package/dist/GregorianCalendar.module.js.map +1 -1
  9. package/dist/HebrewCalendar.main.js.map +1 -1
  10. package/dist/HebrewCalendar.module.js.map +1 -1
  11. package/dist/IndianCalendar.main.js.map +1 -1
  12. package/dist/IndianCalendar.module.js.map +1 -1
  13. package/dist/IslamicCalendar.main.js.map +1 -1
  14. package/dist/IslamicCalendar.module.js.map +1 -1
  15. package/dist/JapaneseCalendar.main.js.map +1 -1
  16. package/dist/JapaneseCalendar.module.js.map +1 -1
  17. package/dist/PersianCalendar.main.js.map +1 -1
  18. package/dist/PersianCalendar.module.js.map +1 -1
  19. package/dist/TaiwanCalendar.main.js.map +1 -1
  20. package/dist/TaiwanCalendar.module.js.map +1 -1
  21. package/dist/conversion.main.js +1 -1
  22. package/dist/conversion.main.js.map +1 -1
  23. package/dist/conversion.mjs +2 -2
  24. package/dist/conversion.module.js +2 -2
  25. package/dist/conversion.module.js.map +1 -1
  26. package/dist/createCalendar.main.js.map +1 -1
  27. package/dist/createCalendar.module.js.map +1 -1
  28. package/dist/import.mjs +2 -2
  29. package/dist/main.js +1 -0
  30. package/dist/main.js.map +1 -1
  31. package/dist/manipulation.main.js.map +1 -1
  32. package/dist/manipulation.module.js.map +1 -1
  33. package/dist/module.js +2 -2
  34. package/dist/module.js.map +1 -1
  35. package/dist/queries.main.js +27 -15
  36. package/dist/queries.main.js.map +1 -1
  37. package/dist/queries.mjs +27 -16
  38. package/dist/queries.module.js +27 -16
  39. package/dist/queries.module.js.map +1 -1
  40. package/dist/string.main.js +9 -9
  41. package/dist/string.main.js.map +1 -1
  42. package/dist/string.mjs +9 -9
  43. package/dist/string.module.js +9 -9
  44. package/dist/string.module.js.map +1 -1
  45. package/dist/types.d.ts +42 -26
  46. package/dist/types.d.ts.map +1 -1
  47. package/package.json +2 -2
  48. package/src/CalendarDate.ts +14 -14
  49. package/src/calendars/BuddhistCalendar.ts +5 -5
  50. package/src/calendars/EthiopicCalendar.ts +10 -10
  51. package/src/calendars/GregorianCalendar.ts +4 -4
  52. package/src/calendars/HebrewCalendar.ts +5 -5
  53. package/src/calendars/IndianCalendar.ts +5 -5
  54. package/src/calendars/IslamicCalendar.ts +7 -7
  55. package/src/calendars/JapaneseCalendar.ts +6 -6
  56. package/src/calendars/PersianCalendar.ts +3 -3
  57. package/src/calendars/TaiwanCalendar.ts +5 -5
  58. package/src/conversion.ts +6 -6
  59. package/src/createCalendar.ts +2 -2
  60. package/src/index.ts +3 -1
  61. package/src/manipulation.ts +7 -7
  62. package/src/queries.ts +40 -26
  63. package/src/string.ts +9 -11
  64. package/src/types.ts +17 -2
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,mBAAmB;AACnB,MAAM,yCAAmB;AAEzB,gEAAgE;AAChE,MAAM,0CAAoB;AAOnB,MAAM,kDAAuB,CAAA,GAAA,yCAAgB;IAGlD,cAAc,EAAU,EAAgB;QACtC,gCAAgC;QAChC,IAAI,OAAO,KAAK,CAAC,cAAc;QAE/B,mBAAmB;QACnB,IAAI,aAAa,KAAK,IAAI,GAAG;QAE7B,iDAAiD;QACjD,IAAI,OAAO,KAAK,CAAA,GAAA,yCAAmB,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI,EAAE,GAAG;QAE7D,IAAI;QACJ,IAAI,OAAO,yCAAmB;YAC5B,gDAAgD;YAChD;YAEA,uDAAuD;Y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AAqB,EAAU;QAC5C,IAAI,KAAK,KAAK,KAAK,KAAK,CAAA,GAAA,yCAAS,EAAE,KAAK,IAAI,GAAG,yCAC7C,OAAO;QAGT,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,KAAK,IAAI,GACnC,OAAO;QAGT,OAAO;IACT;IAEA,gBAAwB;QACtB,6CAA6C;QAC7C,6CAA6C;QAC7C,OAAO;IACT;IAEA,UAAU;QACR,OAAO;YAAC;SAAO;IACjB;IAEA,cAAc,CAAC;;6BAhGf,aAAa;;AAiGf","sources":["packages/@internationalized/date/src/calendars/IndianCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {fromExtendedYear, GregorianCalendar, gregorianToJulianDay, isLeapYear} from './GregorianCalendar';\n\n// Starts in 78 AD,\nconst INDIAN_ERA_START = 78;\n\n// The Indian year starts 80 days later than the Gregorian year.\nconst INDIAN_YEAR_START = 80;\n\n/**\n * The Indian National Calendar is similar to the Gregorian calendar, but with\n * years numbered since the Saka era in 78 AD (Gregorian). There are 12 months\n * in each year, with either 30 or 31 days. Only one era identifier is supported: 'saka'.\n */\nexport class IndianCalendar extends GregorianCalendar {\n identifier = 'indian';\n\n fromJulianDay(jd: number): CalendarDate {\n // Gregorian date for Julian day\n let date = super.fromJulianDay(jd);\n\n // Year in Saka era\n let indianYear = date.year - INDIAN_ERA_START;\n\n // Day number in Gregorian year (starting from 0)\n let yDay = jd - gregorianToJulianDay(date.era, date.year, 1, 1);\n\n let leapMonth: number;\n if (yDay < INDIAN_YEAR_START) {\n // Day is at the end of the preceding Saka year\n indianYear--;\n\n // Days in leapMonth this year, previous Gregorian year\n leapMonth = isLeapYear(date.year - 1) ? 31 : 30;\n yDay += leapMonth + (31 * 5) + (30 * 3) + 10;\n } else {\n // Days in leapMonth this year\n leapMonth = isLeapYear(date.year) ? 31 : 30;\n yDay -= INDIAN_YEAR_START;\n }\n\n let indianMonth: number;\n let indianDay: number;\n if (yDay < leapMonth) {\n indianMonth = 1;\n indianDay = yDay + 1;\n } else {\n let mDay = yDay - leapMonth;\n if (mDay < (31 * 5)) {\n indianMonth = Math.floor(mDay / 31) + 2;\n indianDay = (mDay % 31) + 1;\n } else {\n mDay -= 31 * 5;\n indianMonth = Math.floor(mDay / 30) + 7;\n indianDay = (mDay % 30) + 1;\n }\n }\n\n return new CalendarDate(this, indianYear, indianMonth, indianDay);\n }\n\n toJulianDay(date: AnyCalendarDate) {\n let extendedYear = date.year + INDIAN_ERA_START;\n let [era, year] = fromExtendedYear(extendedYear);\n\n let leapMonth: number;\n let jd: number;\n if (isLeapYear(year)) {\n leapMonth = 31;\n jd = gregorianToJulianDay(era, year, 3, 21);\n } else {\n leapMonth = 30;\n jd = gregorianToJulianDay(era, year, 3, 22);\n }\n\n if (date.month === 1) {\n return jd + date.day - 1;\n }\n\n jd += leapMonth + Math.min(date.month - 2, 5) * 31;\n\n if (date.month >= 8) {\n jd += (date.month - 7) * 30;\n }\n\n jd += date.day - 1;\n return jd;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month === 1 && isLeapYear(date.year + INDIAN_ERA_START)) {\n return 31;\n }\n\n if (date.month >= 2 && date.month <= 6) {\n return 31;\n }\n\n return 30;\n }\n\n getYearsInEra(): number {\n // 9999-12-31 gregorian is 9920-10-10 indian.\n // Round down to 9919 for the last full year.\n return 9919;\n }\n\n getEras() {\n return ['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/B,IAAI,CAAC,KAAK,KAAK,GAAG,CAAA,GAAA,yCAAe,EAAE;QAEnC,IAAI;QACJ,IAAI;QACJ,IAAI,CAAA,GAAA,yCAAS,EAAE,OAAO;YACpB,YAAY;YACZ,KAAK,CAAA,GAAA,yCAAmB,EAAE,KAAK,MAAM,GAAG;QAC1C,OAAO;YACL,YAAY;YACZ,KAAK,CAAA,GAAA,yCAAmB,EAAE,KAAK,MAAM,GAAG;QAC1C;QAEA,IAAI,KAAK,KAAK,KAAK,GACjB,OAAO,KAAK,KAAK,GAAG,GAAG;QAGzB,MAAM,YAAY,KAAK,GAAG,CAAC,KAAK,KAAK,GAAG,GAAG,KAAK;QAEhD,IAAI,KAAK,KAAK,IAAI,GAChB,MAAM,AAAC,CAAA,KAAK,KAAK,GAAG,CAAA,IAAK;QAG3B,MAAM,KAAK,GAAG,GAAG;QACjB,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,KAAK,KAAK,KAAK,CAAA,GAAA,yCAAS,EAAE,KAAK,IAAI,GAAG,yCAC7C,OAAO;QAGT,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,KAAK,IAAI,GACnC,OAAO;QAGT,OAAO;IACT;IAEA,gBAAwB;QACtB,6CAA6C;QAC7C,6CAA6C;QAC7C,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAO;IACjB;IAEA,cAAoB,CAAC;;QAjGhB,qBACL,aAAiC;;AAiGnC","sources":["packages/@internationalized/date/src/calendars/IndianCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {fromExtendedYear, GregorianCalendar, gregorianToJulianDay, isLeapYear} from './GregorianCalendar';\n\n// Starts in 78 AD,\nconst INDIAN_ERA_START = 78;\n\n// The Indian year starts 80 days later than the Gregorian year.\nconst INDIAN_YEAR_START = 80;\n\n/**\n * The Indian National Calendar is similar to the Gregorian calendar, but with\n * years numbered since the Saka era in 78 AD (Gregorian). There are 12 months\n * in each year, with either 30 or 31 days. Only one era identifier is supported: 'saka'.\n */\nexport class IndianCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'indian';\n\n fromJulianDay(jd: number): CalendarDate {\n // Gregorian date for Julian day\n let date = super.fromJulianDay(jd);\n\n // Year in Saka era\n let indianYear = date.year - INDIAN_ERA_START;\n\n // Day number in Gregorian year (starting from 0)\n let yDay = jd - gregorianToJulianDay(date.era, date.year, 1, 1);\n\n let leapMonth: number;\n if (yDay < INDIAN_YEAR_START) {\n // Day is at the end of the preceding Saka year\n indianYear--;\n\n // Days in leapMonth this year, previous Gregorian year\n leapMonth = isLeapYear(date.year - 1) ? 31 : 30;\n yDay += leapMonth + (31 * 5) + (30 * 3) + 10;\n } else {\n // Days in leapMonth this year\n leapMonth = isLeapYear(date.year) ? 31 : 30;\n yDay -= INDIAN_YEAR_START;\n }\n\n let indianMonth: number;\n let indianDay: number;\n if (yDay < leapMonth) {\n indianMonth = 1;\n indianDay = yDay + 1;\n } else {\n let mDay = yDay - leapMonth;\n if (mDay < (31 * 5)) {\n indianMonth = Math.floor(mDay / 31) + 2;\n indianDay = (mDay % 31) + 1;\n } else {\n mDay -= 31 * 5;\n indianMonth = Math.floor(mDay / 30) + 7;\n indianDay = (mDay % 30) + 1;\n }\n }\n\n return new CalendarDate(this, indianYear, indianMonth, indianDay);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let extendedYear = date.year + INDIAN_ERA_START;\n let [era, year] = fromExtendedYear(extendedYear);\n\n let leapMonth: number;\n let jd: number;\n if (isLeapYear(year)) {\n leapMonth = 31;\n jd = gregorianToJulianDay(era, year, 3, 21);\n } else {\n leapMonth = 30;\n jd = gregorianToJulianDay(era, year, 3, 22);\n }\n\n if (date.month === 1) {\n return jd + date.day - 1;\n }\n\n jd += leapMonth + Math.min(date.month - 2, 5) * 31;\n\n if (date.month >= 8) {\n jd += (date.month - 7) * 30;\n }\n\n jd += date.day - 1;\n return jd;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month === 1 && isLeapYear(date.year + INDIAN_ERA_START)) {\n return 31;\n }\n\n if (date.month >= 2 && date.month <= 6) {\n return 31;\n }\n\n return 30;\n }\n\n getYearsInEra(): number {\n // 9999-12-31 gregorian is 9920-10-10 indian.\n // Round down to 9919 for the last full year.\n return 9919;\n }\n\n getEras(): string[] {\n return ['saka'];\n }\n\n balanceDate(): void {}\n}\n"],"names":[],"version":3,"file":"IndianCalendar.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;AAKhG,MAAM,mCAAa,SAAS,gFAAgF;AAC5G,MAAM,0CAAoB,SAAS,4CAA4C;AAC/E,MAAM,4CAAsB;AAC5B,MAAM,0CAAoB;AAC1B,MAAM,4CAAsB;AAE5B,SAAS,yCAAmB,KAAa,EAAE,IAAY,EAAE,KAAa,EAAE,GAAW;IACjF,OAAO,MACL,KAAK,IAAI,CAAC,OAAQ,CAAA,QAAQ,CAAA,KAC1B,AAAC,CAAA,OAAO,CAAA,IAAK,MACb,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,KAAK,IAAG,IAAK,MAC7B,QAAQ;AACZ;AAEA,SAAS,yCAAmB,QAAkB,EAAE,KAAa,EAAE,EAAU;IACvE,IAAI,OAAO,KAAK,KAAK,CAAC,A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F;IAEA,YAAY,IAAqB,EAAU;QACzC,IAAI,KAAK,IAAI,GAAG,6CAAuB,KAAK,IAAI,GAAG,yCACjD,OAAO,KAAK,CAAC,YAAY;QAG3B,OAAO,mCAAa,yCAAmB,KAAK,IAAI,EAAE,KAAK,KAAK,IAAK,CAAA,KAAK,GAAG,GAAG,CAAA;IAC9E;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,IAAI,GAAG,6CAAuB,KAAK,IAAI,GAAG,yCACjD,OAAO,KAAK,CAAC,eAAe;QAG9B,OAAO,0CAAoB,KAAK,IAAI,EAAE,KAAK,KAAK;IAClD;IAEA,cAAc,IAAqB,EAAU;QAC3C,IAAI,KAAK,IAAI,GAAG,6CAAuB,KAAK,IAAI,GAAG,yCACjD,OAAO,KAAK,CAAC,cAAc;QAG7B,OAAO,yCAAmB,KAAK,IAAI;IACrC;IA1EA,aAAc;QACZ,KAAK,SAHP,aAAa;QAIX,IAAI,CAAC,4CACH,6CAAuB,IAAI,YAAY,WAAW,IAAI,CAAC,KAAK,sCAAgB,CAAA,IAAK,EAAE,UAAU,CAAC,IAAI,MAAM;QAG1G,IAAI,CAAC,iDAA2B;YAC9B,kDAA4B,IAAI,YAAY,0CAAoB,4CAAsB;YAEtF,IAAI,YAAY;YAChB,IAAK,IAAI,OAAO,2CAAqB,QAAQ,yCAAmB,OAAQ;gBACtE,+CAAyB,CAAC,OAAO,0CAAoB,GAAG;gBACxD,IAAK,IAAI,IAAI,GAAG,KAAK,IAAI,IACvB,aAAa,0CAAoB,MAAM;YAE3C;QACF;IACF;AA0DF","sources":["packages/@internationalized/date/src/calendars/IslamicCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar} from '../types';\nimport {CalendarDate} from '../CalendarDate';\n\nconst CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian calendar) / CE 622 July 19 (Gregorian calendar)\nconst ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Julian calendar)\nconst UMALQURA_YEAR_START = 1300;\nconst UMALQURA_YEAR_END = 1600;\nconst UMALQURA_START_DAYS = 460322;\n\nfunction islamicToJulianDay(epoch: number, year: number, month: number, day: number): number {\n return day +\n Math.ceil(29.5 * (month - 1)) +\n (year - 1) * 354 +\n Math.floor((3 + 11 * year) / 30) +\n epoch - 1;\n}\n\nfunction julianDayToIslamic(calendar: Calendar, epoch: number, jd: number) {\n let year = Math.floor((30 * (jd - epoch) + 10646) / 10631);\n let month = Math.min(12, Math.ceil((jd - (29 + islamicToJulianDay(epoch, year, 1, 1))) / 29.5) + 1);\n let day = jd - islamicToJulianDay(epoch, year, month, 1) + 1;\n\n return new CalendarDate(calendar, year, month, day);\n}\n\nfunction isLeapYear(year: number): boolean {\n return (14 + 11 * year) % 30 < 11;\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab world.\n * The civil variant uses simple arithmetic rules rather than astronomical calculations to approximate\n * the traditional calendar, which is based on sighting of the crescent moon. It uses Friday, July 16 622 CE (Julian) as the epoch.\n * Each year has 12 months, with either 354 or 355 days depending on whether it is a leap year.\n * Learn more about the available Islamic calendars [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicCivilCalendar implements Calendar {\n identifier = 'islamic-civil';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, CIVIL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate) {\n return islamicToJulianDay(CIVIL_EPOC, date.year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n let length = 29 + date.month % 2;\n if (date.month === 12 && isLeapYear(date.year)) {\n length++;\n }\n\n return length;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 355 : 354;\n }\n\n getYearsInEra(): number {\n // 9999 gregorian\n return 9665;\n }\n\n getEras() {\n return ['AH'];\n }\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab world.\n * The tabular variant uses simple arithmetic rules rather than astronomical calculations to approximate\n * the traditional calendar, which is based on sighting of the crescent moon. It uses Thursday, July 15 622 CE (Julian) as the epoch.\n * Each year has 12 months, with either 354 or 355 days depending on whether it is a leap year.\n * Learn more about the available Islamic calendars [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicTabularCalendar extends IslamicCivilCalendar {\n identifier = 'islamic-tbla';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, ASTRONOMICAL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate) {\n return islamicToJulianDay(ASTRONOMICAL_EPOC, date.year, date.month, date.day);\n }\n}\n\n// Generated by scripts/generate-umalqura.js\nconst UMALQURA_DATA = 'qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=';\nlet UMALQURA_MONTHLENGTH: Uint16Array;\nlet UMALQURA_YEAR_START_TABLE: Uint32Array;\n\nfunction umalquraYearStart(year: number): number {\n return UMALQURA_START_DAYS + UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START];\n}\n\nfunction umalquraMonthLength(year: number, month: number): number {\n let idx = (year - UMALQURA_YEAR_START);\n let mask = (0x01 << (11 - (month - 1)));\n if ((UMALQURA_MONTHLENGTH[idx] & mask) === 0) {\n return 29;\n } else {\n return 30;\n }\n}\n\nfunction umalquraMonthStart(year: number, month: number): number {\n let day = umalquraYearStart(year);\n for (let i = 1; i < month; i++) {\n day += umalquraMonthLength(year, i);\n }\n return day;\n}\n\nfunction umalquraYearLength(year: number): number {\n return UMALQURA_YEAR_START_TABLE[year + 1 - UMALQURA_YEAR_START] - UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START];\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab world.\n * The Umalqura variant is primarily used in Saudi Arabia. It is a lunar calendar, based on astronomical\n * calculations that predict the sighting of a crescent moon. Month and year lengths vary between years\n * depending on these calculations.\n * Learn more about the available Islamic calendars [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicUmalquraCalendar extends IslamicCivilCalendar {\n identifier = 'islamic-umalqura';\n\n constructor() {\n super();\n if (!UMALQURA_MONTHLENGTH) {\n UMALQURA_MONTHLENGTH = new Uint16Array(Uint8Array.from(atob(UMALQURA_DATA), c => c.charCodeAt(0)).buffer);\n }\n\n if (!UMALQURA_YEAR_START_TABLE) {\n UMALQURA_YEAR_START_TABLE = new Uint32Array(UMALQURA_YEAR_END - UMALQURA_YEAR_START + 1);\n\n let yearStart = 0;\n for (let year = UMALQURA_YEAR_START; year <= UMALQURA_YEAR_END; year++) {\n UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START] = yearStart;\n for (let i = 1; i <= 12; i++) {\n yearStart += umalquraMonthLength(year, i);\n }\n }\n }\n }\n\n fromJulianDay(jd: number): CalendarDate {\n let days = jd - CIVIL_EPOC;\n let startDays = umalquraYearStart(UMALQURA_YEAR_START);\n let endDays = umalquraYearStart(UMALQURA_YEAR_END);\n if (days < startDays || days > endDays) {\n return super.fromJulianDay(jd);\n } else {\n let y = UMALQURA_YEAR_START - 1;\n let m = 1;\n let d = 1;\n while (d > 0) {\n y++;\n d = days - umalquraYearStart(y) + 1;\n let yearLength = umalquraYearLength(y);\n if (d === yearLength) {\n m = 12;\n break;\n } else if (d < yearLength) {\n let monthLength = umalquraMonthLength(y, m);\n m = 1;\n while (d > monthLength) {\n d -= monthLength;\n m++;\n monthLength = umalquraMonthLength(y, m);\n }\n break;\n }\n }\n\n return new CalendarDate(this, y, m, (days - umalquraMonthStart(y, m) + 1));\n }\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.toJulianDay(date);\n }\n\n return CIVIL_EPOC + umalquraMonthStart(date.year, date.month) + (date.day - 1);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInMonth(date);\n }\n\n return umalquraMonthLength(date.year, date.month);\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInYear(date);\n }\n\n return umalquraYearLength(date.year);\n }\n}\n"],"names":[],"version":3,"file":"IslamicCalendar.main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;AAKhG,MAAM,mCAAa,SAAS,gFAAgF;AAC5G,MAAM,0CAAoB,SAAS,4CAA4C;AAC/E,MAAM,4CAAsB;AAC5B,MAAM,0CAAoB;AAC1B,MAAM,4CAAsB;AAE5B,SAAS,yCAAmB,KAAa,EAAE,IAAY,EAAE,KAAa,EAAE,GAAW;IACjF,OAAO,MACL,KAAK,IAAI,CAAC,OAAQ,CAAA,QAAQ,CAAA,KAC1B,AAAC,CAAA,OAAO,CAAA,IAAK,MACb,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,KAAK,IAAG,IAAK,MAC7B,QAAQ;AACZ;AAEA,SAAS,yCAAmB,QAAkB,EAAE,KAAa,EAAE,EAAU;IACvE,IAAI,OAAO,KAAK,KAAK,CAAC,AAAC,CAAA,KAAM,CAAA,KAAK,KAAI,IAAK,KAAI,IAAK;IACpD,IAAI,QAAQ,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,AAAC,CAAA,KAAM,CAAA,KAAK,yCAAmB,OAAO,MAAM,GAAG,EAAC,CAAC,IAAK,QAAQ;IACjG,IAAI,MAAM,KAAK,yCAAmB,OAAO,MAAM,OAAO,KAAK;IAE3D,OAAO,IAAI,CAAA,GAAA,sCAAW,EAAE,UAAU,MAAM,OAAO;AACjD;AAEA,SAAS,iCAAW,IAAY;IAC9B,OAAO,AAAC,CAAA,KAAK,KAAK,IAAG,IAAK,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IAClD;IAEA,cAAc,IAAqB,EAAU;QAC3C,IAAI,KAAK,IAAI,GAAG,6CAAuB,KAAK,IAAI,GAAG,yCACjD,OAAO,KAAK,CAAC,cAAc;QAG7B,OAAO,yCAAmB,KAAK,IAAI;IACrC;IA1EA,aAAc;QACZ,KAAK,SAHP,aAAiC;QAI/B,IAAI,CAAC,4CACH,6CAAuB,IAAI,YAAY,WAAW,IAAI,CAAC,KAAK,sCAAgB,CAAA,IAAK,EAAE,UAAU,CAAC,IAAI,MAAM;QAG1G,IAAI,CAAC,iDAA2B;YAC9B,kDAA4B,IAAI,YAAY,0CAAoB,4CAAsB;YAEtF,IAAI,YAAY;YAChB,IAAK,IAAI,OAAO,2CAAqB,QAAQ,yCAAmB,OAAQ;gBACtE,+CAAyB,CAAC,OAAO,0CAAoB,GAAG;gBACxD,IAAK,IAAI,IAAI,GAAG,KAAK,IAAI,IACvB,aAAa,0CAAoB,MAAM;YAE3C;QACF;IACF;AA0DF","sources":["packages/@internationalized/date/src/calendars/IslamicCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\n\nconst CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian calendar) / CE 622 July 19 (Gregorian calendar)\nconst ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Julian calendar)\nconst UMALQURA_YEAR_START = 1300;\nconst UMALQURA_YEAR_END = 1600;\nconst UMALQURA_START_DAYS = 460322;\n\nfunction islamicToJulianDay(epoch: number, year: number, month: number, day: number): number {\n return day +\n Math.ceil(29.5 * (month - 1)) +\n (year - 1) * 354 +\n Math.floor((3 + 11 * year) / 30) +\n epoch - 1;\n}\n\nfunction julianDayToIslamic(calendar: Calendar, epoch: number, jd: number) {\n let year = Math.floor((30 * (jd - epoch) + 10646) / 10631);\n let month = Math.min(12, Math.ceil((jd - (29 + islamicToJulianDay(epoch, year, 1, 1))) / 29.5) + 1);\n let day = jd - islamicToJulianDay(epoch, year, month, 1) + 1;\n\n return new CalendarDate(calendar, year, month, day);\n}\n\nfunction isLeapYear(year: number): boolean {\n return (14 + 11 * year) % 30 < 11;\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab world.\n * The civil variant uses simple arithmetic rules rather than astronomical calculations to approximate\n * the traditional calendar, which is based on sighting of the crescent moon. It uses Friday, July 16 622 CE (Julian) as the epoch.\n * Each year has 12 months, with either 354 or 355 days depending on whether it is a leap year.\n * Learn more about the available Islamic calendars [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicCivilCalendar implements Calendar {\n identifier: CalendarIdentifier = 'islamic-civil';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, CIVIL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return islamicToJulianDay(CIVIL_EPOC, date.year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n let length = 29 + date.month % 2;\n if (date.month === 12 && isLeapYear(date.year)) {\n length++;\n }\n\n return length;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 355 : 354;\n }\n\n getYearsInEra(): number {\n // 9999 gregorian\n return 9665;\n }\n\n getEras(): string[] {\n return ['AH'];\n }\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab world.\n * The tabular variant uses simple arithmetic rules rather than astronomical calculations to approximate\n * the traditional calendar, which is based on sighting of the crescent moon. It uses Thursday, July 15 622 CE (Julian) as the epoch.\n * Each year has 12 months, with either 354 or 355 days depending on whether it is a leap year.\n * Learn more about the available Islamic calendars [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicTabularCalendar extends IslamicCivilCalendar {\n identifier: CalendarIdentifier = 'islamic-tbla';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, ASTRONOMICAL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return islamicToJulianDay(ASTRONOMICAL_EPOC, date.year, date.month, date.day);\n }\n}\n\n// Generated by scripts/generate-umalqura.js\nconst UMALQURA_DATA = 'qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=';\nlet UMALQURA_MONTHLENGTH: Uint16Array;\nlet UMALQURA_YEAR_START_TABLE: Uint32Array;\n\nfunction umalquraYearStart(year: number): number {\n return UMALQURA_START_DAYS + UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START];\n}\n\nfunction umalquraMonthLength(year: number, month: number): number {\n let idx = (year - UMALQURA_YEAR_START);\n let mask = (0x01 << (11 - (month - 1)));\n if ((UMALQURA_MONTHLENGTH[idx] & mask) === 0) {\n return 29;\n } else {\n return 30;\n }\n}\n\nfunction umalquraMonthStart(year: number, month: number): number {\n let day = umalquraYearStart(year);\n for (let i = 1; i < month; i++) {\n day += umalquraMonthLength(year, i);\n }\n return day;\n}\n\nfunction umalquraYearLength(year: number): number {\n return UMALQURA_YEAR_START_TABLE[year + 1 - UMALQURA_YEAR_START] - UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START];\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab world.\n * The Umalqura variant is primarily used in Saudi Arabia. It is a lunar calendar, based on astronomical\n * calculations that predict the sighting of a crescent moon. Month and year lengths vary between years\n * depending on these calculations.\n * Learn more about the available Islamic calendars [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicUmalquraCalendar extends IslamicCivilCalendar {\n identifier: CalendarIdentifier = 'islamic-umalqura';\n\n constructor() {\n super();\n if (!UMALQURA_MONTHLENGTH) {\n UMALQURA_MONTHLENGTH = new Uint16Array(Uint8Array.from(atob(UMALQURA_DATA), c => c.charCodeAt(0)).buffer);\n }\n\n if (!UMALQURA_YEAR_START_TABLE) {\n UMALQURA_YEAR_START_TABLE = new Uint32Array(UMALQURA_YEAR_END - UMALQURA_YEAR_START + 1);\n\n let yearStart = 0;\n for (let year = UMALQURA_YEAR_START; year <= UMALQURA_YEAR_END; year++) {\n UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START] = yearStart;\n for (let i = 1; i <= 12; i++) {\n yearStart += umalquraMonthLength(year, i);\n }\n }\n }\n }\n\n fromJulianDay(jd: number): CalendarDate {\n let days = jd - CIVIL_EPOC;\n let startDays = umalquraYearStart(UMALQURA_YEAR_START);\n let endDays = umalquraYearStart(UMALQURA_YEAR_END);\n if (days < startDays || days > endDays) {\n return super.fromJulianDay(jd);\n } else {\n let y = UMALQURA_YEAR_START - 1;\n let m = 1;\n let d = 1;\n while (d > 0) {\n y++;\n d = days - umalquraYearStart(y) + 1;\n let yearLength = umalquraYearLength(y);\n if (d === yearLength) {\n m = 12;\n break;\n } else if (d < yearLength) {\n let monthLength = umalquraMonthLength(y, m);\n m = 1;\n while (d > monthLength) {\n d -= monthLength;\n m++;\n monthLength = umalquraMonthLength(y, m);\n }\n break;\n }\n }\n\n return new CalendarDate(this, y, m, (days - umalquraMonthStart(y, m) + 1));\n }\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.toJulianDay(date);\n }\n\n return CIVIL_EPOC + umalquraMonthStart(date.year, date.month) + (date.day - 1);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInMonth(date);\n }\n\n return umalquraMonthLength(date.year, date.month);\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInYear(date);\n }\n\n return umalquraYearLength(date.year);\n }\n}\n"],"names":[],"version":3,"file":"IslamicCalendar.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;AAAA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,iDAA2B;YAC9B,kDAA4B,IAAI,YAAY,0CAAoB,4CAAsB;YAEtF,IAAI,YAAY;YAChB,IAAK,IAAI,OAAO,2CAAqB,QAAQ,yCAAmB,OAAQ;gBACtE,+CAAyB,CAAC,OAAO,0CAAoB,GAAG;gBACxD,IAAK,IAAI,IAAI,GAAG,KAAK,IAAI,IACvB,aAAa,0CAAoB,MAAM;YAE3C;QACF;IACF;AA0DF","sources":["packages/@internationalized/date/src/calendars/IslamicCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar} from '../types';\nimport {CalendarDate} from '../CalendarDate';\n\nconst CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian calendar) / CE 622 July 19 (Gregorian calendar)\nconst ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Julian calendar)\nconst UMALQURA_YEAR_START = 1300;\nconst UMALQURA_YEAR_END = 1600;\nconst UMALQURA_START_DAYS = 460322;\n\nfunction islamicToJulianDay(epoch: number, year: number, month: number, day: number): number {\n return day +\n Math.ceil(29.5 * (month - 1)) +\n (year - 1) * 354 +\n Math.floor((3 + 11 * year) / 30) +\n epoch - 1;\n}\n\nfunction julianDayToIslamic(calendar: Calendar, epoch: number, jd: number) {\n let year = Math.floor((30 * (jd - epoch) + 10646) / 10631);\n let month = Math.min(12, Math.ceil((jd - (29 + islamicToJulianDay(epoch, year, 1, 1))) / 29.5) + 1);\n let day = jd - islamicToJulianDay(epoch, year, month, 1) + 1;\n\n return new CalendarDate(calendar, year, month, day);\n}\n\nfunction isLeapYear(year: number): boolean {\n return (14 + 11 * year) % 30 < 11;\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab world.\n * The civil variant uses simple arithmetic rules rather than astronomical calculations to approximate\n * the traditional calendar, which is based on sighting of the crescent moon. It uses Friday, July 16 622 CE (Julian) as the epoch.\n * Each year has 12 months, with either 354 or 355 days depending on whether it is a leap year.\n * Learn more about the available Islamic calendars [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicCivilCalendar implements Calendar {\n identifier = 'islamic-civil';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, CIVIL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate) {\n return islamicToJulianDay(CIVIL_EPOC, date.year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n let length = 29 + date.month % 2;\n if (date.month === 12 && isLeapYear(date.year)) {\n length++;\n }\n\n return length;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 355 : 354;\n }\n\n getYearsInEra(): number {\n // 9999 gregorian\n return 9665;\n }\n\n getEras() {\n return ['AH'];\n }\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab world.\n * The tabular variant uses simple arithmetic rules rather than astronomical calculations to approximate\n * the traditional calendar, which is based on sighting of the crescent moon. It uses Thursday, July 15 622 CE (Julian) as the epoch.\n * Each year has 12 months, with either 354 or 355 days depending on whether it is a leap year.\n * Learn more about the available Islamic calendars [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicTabularCalendar extends IslamicCivilCalendar {\n identifier = 'islamic-tbla';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, ASTRONOMICAL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate) {\n return islamicToJulianDay(ASTRONOMICAL_EPOC, date.year, date.month, date.day);\n }\n}\n\n// Generated by scripts/generate-umalqura.js\nconst UMALQURA_DATA = 'qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=';\nlet UMALQURA_MONTHLENGTH: Uint16Array;\nlet UMALQURA_YEAR_START_TABLE: Uint32Array;\n\nfunction umalquraYearStart(year: number): number {\n return UMALQURA_START_DAYS + UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START];\n}\n\nfunction umalquraMonthLength(year: number, month: number): number {\n let idx = (year - UMALQURA_YEAR_START);\n let mask = (0x01 << (11 - (month - 1)));\n if ((UMALQURA_MONTHLENGTH[idx] & mask) === 0) {\n return 29;\n } else {\n return 30;\n }\n}\n\nfunction umalquraMonthStart(year: number, month: number): number {\n let day = umalquraYearStart(year);\n for (let i = 1; i < month; i++) {\n day += umalquraMonthLength(year, i);\n }\n return day;\n}\n\nfunction umalquraYearLength(year: number): number {\n return UMALQURA_YEAR_START_TABLE[year + 1 - UMALQURA_YEAR_START] - UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START];\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab world.\n * The Umalqura variant is primarily used in Saudi Arabia. It is a lunar calendar, based on astronomical\n * calculations that predict the sighting of a crescent moon. Month and year lengths vary between years\n * depending on these calculations.\n * Learn more about the available Islamic calendars [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicUmalquraCalendar extends IslamicCivilCalendar {\n identifier = 'islamic-umalqura';\n\n constructor() {\n super();\n if (!UMALQURA_MONTHLENGTH) {\n UMALQURA_MONTHLENGTH = new Uint16Array(Uint8Array.from(atob(UMALQURA_DATA), c => c.charCodeAt(0)).buffer);\n }\n\n if (!UMALQURA_YEAR_START_TABLE) {\n UMALQURA_YEAR_START_TABLE = new Uint32Array(UMALQURA_YEAR_END - UMALQURA_YEAR_START + 1);\n\n let yearStart = 0;\n for (let year = UMALQURA_YEAR_START; year <= UMALQURA_YEAR_END; year++) {\n UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START] = yearStart;\n for (let i = 1; i <= 12; i++) {\n yearStart += umalquraMonthLength(year, i);\n }\n }\n }\n }\n\n fromJulianDay(jd: number): CalendarDate {\n let days = jd - CIVIL_EPOC;\n let startDays = umalquraYearStart(UMALQURA_YEAR_START);\n let endDays = umalquraYearStart(UMALQURA_YEAR_END);\n if (days < startDays || days > endDays) {\n return super.fromJulianDay(jd);\n } else {\n let y = UMALQURA_YEAR_START - 1;\n let m = 1;\n let d = 1;\n while (d > 0) {\n y++;\n d = days - umalquraYearStart(y) + 1;\n let yearLength = umalquraYearLength(y);\n if (d === yearLength) {\n m = 12;\n break;\n } else if (d < yearLength) {\n let monthLength = umalquraMonthLength(y, m);\n m = 1;\n while (d > monthLength) {\n d -= monthLength;\n m++;\n monthLength = umalquraMonthLength(y, m);\n }\n break;\n }\n }\n\n return new CalendarDate(this, y, m, (days - umalquraMonthStart(y, m) + 1));\n }\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.toJulianDay(date);\n }\n\n return CIVIL_EPOC + umalquraMonthStart(date.year, date.month) + (date.day - 1);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInMonth(date);\n }\n\n return umalquraMonthLength(date.year, date.month);\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInYear(date);\n }\n\n return umalquraYearLength(date.year);\n }\n}\n"],"names":[],"version":3,"file":"IslamicCalendar.module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;AAKhG,MAAM,mCAAa,SAAS,gFAAgF;AAC5G,MAAM,0CAAoB,SAAS,4CAA4C;AAC/E,MAAM,4CAAsB;AAC5B,MAAM,0CAAoB;AAC1B,MAAM,4CAAsB;AAE5B,SAAS,yCAAmB,KAAa,EAAE,IAAY,EAAE,KAAa,EAAE,GAAW;IACjF,OAAO,MACL,KAAK,IAAI,CAAC,OAAQ,CAAA,QAAQ,CAAA,KAC1B,AAAC,CAAA,OAAO,CAAA,IAAK,MACb,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,KAAK,IAAG,IAAK,M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;oBACA;gBACF;YACF;YAEA,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,IAAI,EAAE,GAAG,GAAI,OAAO,yCAAmB,GAAG,KAAK;QACzE;IACF;IAEA,YAAY,IAAqB,EAAU;QACzC,IAAI,KAAK,IAAI,GAAG,6CAAuB,KAAK,IAAI,GAAG,yCACjD,OAAO,KAAK,CAAC,YAAY;QAG3B,OAAO,mCAAa,yCAAmB,KAAK,IAAI,EAAE,KAAK,KAAK,IAAK,CAAA,KAAK,GAAG,GAAG,CAAA;IAC9E;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,IAAI,GAAG,6CAAuB,KAAK,IAAI,GAAG,yCACjD,OAAO,KAAK,CAAC,eAAe;QAG9B,OAAO,0CAAoB,KAAK,IAAI,EAAE,KAAK,KAAK;IAClD;IAEA,cAAc,IAAqB,EAAU;QAC3C,IAAI,KAAK,IAAI,GAAG,6CAAuB,KAAK,IAAI,GAAG,yCACjD,OAAO,KAAK,CAAC,cAAc;QAG7B,OAAO,yCAAmB,KAAK,IAAI;IACrC;IA1EA,aAAc;QACZ,KAAK,SAHP,aAAiC;QAI/B,IAAI,CAAC,4CACH,6CAAuB,IAAI,YAAY,WAAW,IAAI,CAAC,KAAK,sCAAgB,CAAA,IAAK,EAAE,UAAU,CAAC,IAAI,MAAM;QAG1G,IAAI,CAAC,iDAA2B;YAC9B,kDAA4B,IAAI,YAAY,0CAAoB,4CAAsB;YAEtF,IAAI,YAAY;YAChB,IAAK,IAAI,OAAO,2CAAqB,QAAQ,yCAAmB,OAAQ;gBACtE,+CAAyB,CAAC,OAAO,0CAAoB,GAAG;gBACxD,IAAK,IAAI,IAAI,GAAG,KAAK,IAAI,IACvB,aAAa,0CAAoB,MAAM;YAE3C;QACF;IACF;AA0DF","sources":["packages/@internationalized/date/src/calendars/IslamicCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\n\nconst CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian calendar) / CE 622 July 19 (Gregorian calendar)\nconst ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Julian calendar)\nconst UMALQURA_YEAR_START = 1300;\nconst UMALQURA_YEAR_END = 1600;\nconst UMALQURA_START_DAYS = 460322;\n\nfunction islamicToJulianDay(epoch: number, year: number, month: number, day: number): number {\n return day +\n Math.ceil(29.5 * (month - 1)) +\n (year - 1) * 354 +\n Math.floor((3 + 11 * year) / 30) +\n epoch - 1;\n}\n\nfunction julianDayToIslamic(calendar: Calendar, epoch: number, jd: number) {\n let year = Math.floor((30 * (jd - epoch) + 10646) / 10631);\n let month = Math.min(12, Math.ceil((jd - (29 + islamicToJulianDay(epoch, year, 1, 1))) / 29.5) + 1);\n let day = jd - islamicToJulianDay(epoch, year, month, 1) + 1;\n\n return new CalendarDate(calendar, year, month, day);\n}\n\nfunction isLeapYear(year: number): boolean {\n return (14 + 11 * year) % 30 < 11;\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab world.\n * The civil variant uses simple arithmetic rules rather than astronomical calculations to approximate\n * the traditional calendar, which is based on sighting of the crescent moon. It uses Friday, July 16 622 CE (Julian) as the epoch.\n * Each year has 12 months, with either 354 or 355 days depending on whether it is a leap year.\n * Learn more about the available Islamic calendars [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicCivilCalendar implements Calendar {\n identifier: CalendarIdentifier = 'islamic-civil';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, CIVIL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return islamicToJulianDay(CIVIL_EPOC, date.year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n let length = 29 + date.month % 2;\n if (date.month === 12 && isLeapYear(date.year)) {\n length++;\n }\n\n return length;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 355 : 354;\n }\n\n getYearsInEra(): number {\n // 9999 gregorian\n return 9665;\n }\n\n getEras(): string[] {\n return ['AH'];\n }\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab world.\n * The tabular variant uses simple arithmetic rules rather than astronomical calculations to approximate\n * the traditional calendar, which is based on sighting of the crescent moon. It uses Thursday, July 15 622 CE (Julian) as the epoch.\n * Each year has 12 months, with either 354 or 355 days depending on whether it is a leap year.\n * Learn more about the available Islamic calendars [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicTabularCalendar extends IslamicCivilCalendar {\n identifier: CalendarIdentifier = 'islamic-tbla';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, ASTRONOMICAL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return islamicToJulianDay(ASTRONOMICAL_EPOC, date.year, date.month, date.day);\n }\n}\n\n// Generated by scripts/generate-umalqura.js\nconst UMALQURA_DATA = 'qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=';\nlet UMALQURA_MONTHLENGTH: Uint16Array;\nlet UMALQURA_YEAR_START_TABLE: Uint32Array;\n\nfunction umalquraYearStart(year: number): number {\n return UMALQURA_START_DAYS + UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START];\n}\n\nfunction umalquraMonthLength(year: number, month: number): number {\n let idx = (year - UMALQURA_YEAR_START);\n let mask = (0x01 << (11 - (month - 1)));\n if ((UMALQURA_MONTHLENGTH[idx] & mask) === 0) {\n return 29;\n } else {\n return 30;\n }\n}\n\nfunction umalquraMonthStart(year: number, month: number): number {\n let day = umalquraYearStart(year);\n for (let i = 1; i < month; i++) {\n day += umalquraMonthLength(year, i);\n }\n return day;\n}\n\nfunction umalquraYearLength(year: number): number {\n return UMALQURA_YEAR_START_TABLE[year + 1 - UMALQURA_YEAR_START] - UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START];\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab world.\n * The Umalqura variant is primarily used in Saudi Arabia. It is a lunar calendar, based on astronomical\n * calculations that predict the sighting of a crescent moon. Month and year lengths vary between years\n * depending on these calculations.\n * Learn more about the available Islamic calendars [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicUmalquraCalendar extends IslamicCivilCalendar {\n identifier: CalendarIdentifier = 'islamic-umalqura';\n\n constructor() {\n super();\n if (!UMALQURA_MONTHLENGTH) {\n UMALQURA_MONTHLENGTH = new Uint16Array(Uint8Array.from(atob(UMALQURA_DATA), c => c.charCodeAt(0)).buffer);\n }\n\n if (!UMALQURA_YEAR_START_TABLE) {\n UMALQURA_YEAR_START_TABLE = new Uint32Array(UMALQURA_YEAR_END - UMALQURA_YEAR_START + 1);\n\n let yearStart = 0;\n for (let year = UMALQURA_YEAR_START; year <= UMALQURA_YEAR_END; year++) {\n UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START] = yearStart;\n for (let i = 1; i <= 12; i++) {\n yearStart += umalquraMonthLength(year, i);\n }\n }\n }\n }\n\n fromJulianDay(jd: number): CalendarDate {\n let days = jd - CIVIL_EPOC;\n let startDays = umalquraYearStart(UMALQURA_YEAR_START);\n let endDays = umalquraYearStart(UMALQURA_YEAR_END);\n if (days < startDays || days > endDays) {\n return super.fromJulianDay(jd);\n } else {\n let y = UMALQURA_YEAR_START - 1;\n let m = 1;\n let d = 1;\n while (d > 0) {\n y++;\n d = days - umalquraYearStart(y) + 1;\n let yearLength = umalquraYearLength(y);\n if (d === yearLength) {\n m = 12;\n break;\n } else if (d < yearLength) {\n let monthLength = umalquraMonthLength(y, m);\n m = 1;\n while (d > monthLength) {\n d -= monthLength;\n m++;\n monthLength = umalquraMonthLength(y, m);\n }\n break;\n }\n }\n\n return new CalendarDate(this, y, m, (days - umalquraMonthStart(y, m) + 1));\n }\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.toJulianDay(date);\n }\n\n return CIVIL_EPOC + umalquraMonthStart(date.year, date.month) + (date.day - 1);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInMonth(date);\n }\n\n return umalquraMonthLength(date.year, date.month);\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInYear(date);\n }\n\n return umalquraYearLength(date.year);\n }\n}\n"],"names":[],"version":3,"file":"IslamicCalendar.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;AAOhG,MAAM,wCAAkB;IAAC;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAG;IAAE;QAAC;QAAM;QAAI;KAAG;IAAE;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAE;CAAC;AACjG,MAAM,sCAAgB;IAAC;QAAC;QAAM;QAAG;KAAG;IAAE;QAAC;QAAM;QAAI;KAAG;IAAE;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAG;CAAC;AAClF,MAAM,oCAAc;IAAC;IAAM;IAAM;IAAM;IAAM;CAAK;AAClD,MAAM,kCAAY;IAAC;IAAS;IAAU;IAAS;IAAU;CAAQ;AAEjE,SAAS,+CAAyB,IAAqB;IACrD,MAAM,MAAM,sCAAgB,SAAS,CAAC,CAAC,CAAC,MAAM,OAAO,IAAI;QACvD,IAAI,KAAK,IAAI,GAAG,MACd,OAAO;QAGT,IAAI,KAAK,IAAI,KAAK,QAAQ,KAAK,KAAK,GAAG,OACrC,OAAO;QAGT,IAAI,KAAK,IAAI,KAAK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Ae,kCAAY;IAC1C;IAEA,sBAAsB,IAAqB,EAAU;QACnD,IAAI,QAAQ,kCAAY;QACxB,OAAO,QAAQ,KAAK,CAAC,EAAE,GAAG;IAC5B;IAEA,qBAAqB,IAAqB,EAAU;QAClD,IAAI,QAAQ,kCAAY;QACxB,OAAO,SAAS,KAAK,KAAK,KAAK,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,GAAG;IACvD;;6BAhGA,aAAa;;AAiGf;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,KAAK,IAAI,KAAK,GAAG;QACnB,IAAI,MAAM,gCAAU,OAAO,CAAC,KAAK,GAAG;QACpC,OAAO,qCAAe,CAAC,IAAI;IAC7B;AACF","sources":["packages/@internationalized/date/src/calendars/JapaneseCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst ERA_START_DATES = [[1868, 9, 8], [1912, 7, 30], [1926, 12, 25], [1989, 1, 8], [2019, 5, 1]];\nconst ERA_END_DATES = [[1912, 7, 29], [1926, 12, 24], [1989, 1, 7], [2019, 4, 30]];\nconst ERA_ADDENDS = [1867, 1911, 1925, 1988, 2018];\nconst ERA_NAMES = ['meiji', 'taisho', 'showa', 'heisei', 'reiwa'];\n\nfunction findEraFromGregorianDate(date: AnyCalendarDate) {\n const idx = ERA_START_DATES.findIndex(([year, month, day]) => {\n if (date.year < year) {\n return true;\n }\n\n if (date.year === year && date.month < month) {\n return true;\n }\n\n if (date.year === year && date.month === month && date.day < day) {\n return true;\n }\n\n return false;\n });\n\n if (idx === -1) {\n return ERA_START_DATES.length - 1;\n }\n\n if (idx === 0) {\n return 0;\n }\n\n return idx - 1;\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let eraAddend = ERA_ADDENDS[ERA_NAMES.indexOf(date.era)];\n if (!eraAddend) {\n throw new Error('Unknown era: ' + date.era);\n }\n\n return new CalendarDate(\n date.year + eraAddend,\n date.month,\n date.day\n );\n}\n\n/**\n * The Japanese calendar is based on the Gregorian calendar, but with eras for the reign of each Japanese emperor.\n * Whenever a new emperor ascends to the throne, a new era begins and the year starts again from 1.\n * Note that eras before 1868 (Gregorian) are not currently supported by this implementation.\n */\nexport class JapaneseCalendar extends GregorianCalendar {\n identifier = 'japanese';\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let era = findEraFromGregorianDate(date);\n\n return new CalendarDate(\n this,\n ERA_NAMES[era],\n date.year - ERA_ADDENDS[era],\n date.month,\n date.day\n );\n }\n\n toJulianDay(date: AnyCalendarDate) {\n return super.toJulianDay(toGregorian(date));\n }\n\n balanceDate(date: Mutable<AnyCalendarDate>) {\n let gregorianDate = toGregorian(date);\n let era = findEraFromGregorianDate(gregorianDate);\n\n if (ERA_NAMES[era] !== date.era) {\n date.era = ERA_NAMES[era];\n date.year = gregorianDate.year - ERA_ADDENDS[era];\n }\n\n // Constrain in case we went before the first supported era.\n this.constrainDate(date);\n }\n\n constrainDate(date: Mutable<AnyCalendarDate>) {\n let idx = ERA_NAMES.indexOf(date.era);\n let end = ERA_END_DATES[idx];\n if (end != null) {\n let [endYear, endMonth, endDay] = end;\n\n // Constrain the year to the maximum possible value in the era.\n // Then constrain the month and day fields within that.\n let maxYear = endYear - ERA_ADDENDS[idx];\n date.year = Math.max(1, Math.min(maxYear, date.year));\n if (date.year === maxYear) {\n date.month = Math.min(endMonth, date.month);\n\n if (date.month === endMonth) {\n date.day = Math.min(endDay, date.day);\n }\n }\n }\n\n if (date.year === 1 && idx >= 0) {\n let [, startMonth, startDay] = ERA_START_DATES[idx];\n date.month = Math.max(startMonth, date.month);\n\n if (date.month === startMonth) {\n date.day = Math.max(startDay, date.day);\n }\n }\n }\n\n getEras() {\n return ERA_NAMES;\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n // Get the number of years in the era, taking into account the date's month and day fields.\n let era = ERA_NAMES.indexOf(date.era);\n let cur = ERA_START_DATES[era];\n let next = ERA_START_DATES[era + 1];\n if (next == null) {\n // 9999 gregorian is the maximum year allowed.\n return 9999 - cur[0] + 1;\n }\n\n let years = next[0] - cur[0];\n\n if (date.month < next[1] || (date.month === next[1] && date.day < next[2])) {\n years++;\n }\n\n return years;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getMinimumMonthInYear(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start ? start[1] : 1;\n }\n\n getMinimumDayInMonth(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start && date.month === start[1] ? start[2] : 1;\n }\n}\n\nfunction getMinimums(date: AnyCalendarDate) {\n if (date.year === 1) {\n let idx = ERA_NAMES.indexOf(date.era);\n return ERA_START_DATES[idx];\n }\n}\n"],"names":[],"version":3,"file":"JapaneseCalendar.main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;AAOhG,MAAM,wCAAkB;IAAC;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAG;IAAE;QAAC;QAAM;QAAI;KAAG;IAAE;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAE;CAAC;AACjG,MAAM,sCAAgB;IAAC;QAAC;QAAM;QAAG;KAAG;I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C,KAAK,GAAG;QACpC,IAAI,MAAM,qCAAe,CAAC,IAAI;QAC9B,IAAI,OAAO,qCAAe,CAAC,MAAM,EAAE;QACnC,IAAI,QAAQ,MACV,8CAA8C;QAC9C,OAAO,OAAO,GAAG,CAAC,EAAE,GAAG;QAGzB,IAAI,QAAQ,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE;QAE5B,IAAI,KAAK,KAAK,GAAG,IAAI,CAAC,EAAE,IAAK,KAAK,KAAK,KAAK,IAAI,CAAC,EAAE,IAAI,KAAK,GAAG,GAAG,IAAI,CAAC,EAAE,EACvE;QAGF,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,sBAAsB,IAAqB,EAAU;QACnD,IAAI,QAAQ,kCAAY;QACxB,OAAO,QAAQ,KAAK,CAAC,EAAE,GAAG;IAC5B;IAEA,qBAAqB,IAAqB,EAAU;QAClD,IAAI,QAAQ,kCAAY;QACxB,OAAO,SAAS,KAAK,KAAK,KAAK,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,GAAG;IACvD;;QAjGK,qBACL,aAAiC;;AAiGnC;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,KAAK,IAAI,KAAK,GAAG;QACnB,IAAI,MAAM,gCAAU,OAAO,CAAC,KAAK,GAAG;QACpC,OAAO,qCAAe,CAAC,IAAI;IAC7B;AACF","sources":["packages/@internationalized/date/src/calendars/JapaneseCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst ERA_START_DATES = [[1868, 9, 8], [1912, 7, 30], [1926, 12, 25], [1989, 1, 8], [2019, 5, 1]];\nconst ERA_END_DATES = [[1912, 7, 29], [1926, 12, 24], [1989, 1, 7], [2019, 4, 30]];\nconst ERA_ADDENDS = [1867, 1911, 1925, 1988, 2018];\nconst ERA_NAMES = ['meiji', 'taisho', 'showa', 'heisei', 'reiwa'];\n\nfunction findEraFromGregorianDate(date: AnyCalendarDate) {\n const idx = ERA_START_DATES.findIndex(([year, month, day]) => {\n if (date.year < year) {\n return true;\n }\n\n if (date.year === year && date.month < month) {\n return true;\n }\n\n if (date.year === year && date.month === month && date.day < day) {\n return true;\n }\n\n return false;\n });\n\n if (idx === -1) {\n return ERA_START_DATES.length - 1;\n }\n\n if (idx === 0) {\n return 0;\n }\n\n return idx - 1;\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let eraAddend = ERA_ADDENDS[ERA_NAMES.indexOf(date.era)];\n if (!eraAddend) {\n throw new Error('Unknown era: ' + date.era);\n }\n\n return new CalendarDate(\n date.year + eraAddend,\n date.month,\n date.day\n );\n}\n\n/**\n * The Japanese calendar is based on the Gregorian calendar, but with eras for the reign of each Japanese emperor.\n * Whenever a new emperor ascends to the throne, a new era begins and the year starts again from 1.\n * Note that eras before 1868 (Gregorian) are not currently supported by this implementation.\n */\nexport class JapaneseCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'japanese';\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let era = findEraFromGregorianDate(date);\n\n return new CalendarDate(\n this,\n ERA_NAMES[era],\n date.year - ERA_ADDENDS[era],\n date.month,\n date.day\n );\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n balanceDate(date: Mutable<AnyCalendarDate>): void {\n let gregorianDate = toGregorian(date);\n let era = findEraFromGregorianDate(gregorianDate);\n\n if (ERA_NAMES[era] !== date.era) {\n date.era = ERA_NAMES[era];\n date.year = gregorianDate.year - ERA_ADDENDS[era];\n }\n\n // Constrain in case we went before the first supported era.\n this.constrainDate(date);\n }\n\n constrainDate(date: Mutable<AnyCalendarDate>): void {\n let idx = ERA_NAMES.indexOf(date.era);\n let end = ERA_END_DATES[idx];\n if (end != null) {\n let [endYear, endMonth, endDay] = end;\n\n // Constrain the year to the maximum possible value in the era.\n // Then constrain the month and day fields within that.\n let maxYear = endYear - ERA_ADDENDS[idx];\n date.year = Math.max(1, Math.min(maxYear, date.year));\n if (date.year === maxYear) {\n date.month = Math.min(endMonth, date.month);\n\n if (date.month === endMonth) {\n date.day = Math.min(endDay, date.day);\n }\n }\n }\n\n if (date.year === 1 && idx >= 0) {\n let [, startMonth, startDay] = ERA_START_DATES[idx];\n date.month = Math.max(startMonth, date.month);\n\n if (date.month === startMonth) {\n date.day = Math.max(startDay, date.day);\n }\n }\n }\n\n getEras(): string[] {\n return ERA_NAMES;\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n // Get the number of years in the era, taking into account the date's month and day fields.\n let era = ERA_NAMES.indexOf(date.era);\n let cur = ERA_START_DATES[era];\n let next = ERA_START_DATES[era + 1];\n if (next == null) {\n // 9999 gregorian is the maximum year allowed.\n return 9999 - cur[0] + 1;\n }\n\n let years = next[0] - cur[0];\n\n if (date.month < next[1] || (date.month === next[1] && date.day < next[2])) {\n years++;\n }\n\n return years;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getMinimumMonthInYear(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start ? start[1] : 1;\n }\n\n getMinimumDayInMonth(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start && date.month === start[1] ? start[2] : 1;\n }\n}\n\nfunction getMinimums(date: AnyCalendarDate) {\n if (date.year === 1) {\n let idx = ERA_NAMES.indexOf(date.era);\n return ERA_START_DATES[idx];\n }\n}\n"],"names":[],"version":3,"file":"JapaneseCalendar.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;AAOhG,MAAM,wCAAkB;IAAC;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAG;IAAE;QAAC;QAAM;QAAI;KAAG;IAAE;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAE;CAAC;AACjG,MAAM,sCAAgB;IAAC;QAAC;QAAM;QAAG;KAAG;IAAE;QAAC;QAAM;QAAI;KAAG;IAAE;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAG;CAAC;AAClF,MAAM,oCAAc;IAAC;IAAM;IAAM;IAAM;IAAM;CAAK;AAClD,MAAM,kCAAY;IAAC;IAAS;IAAU;IAAS;IAAU;CAAQ;AAEjE,SAAS,+CAAyB,IAAqB;IACrD,MAAM,MAAM,sCAAgB,SAAS,CAAC,CAAC,CAAC,MAAM,OAAO,IAAI;QACvD,IAAI,KAAK,IAAI,GAAG,MACd,OAAO;QAGT,IAAI,KAAK,IAAI,KAAK,QAAQ,KAAK,KAAK,GAAG,OACrC,OAAO;QAGT,IAAI,KAAK,IAAI,KAAK,QAAQ,KAAK,KAAK,KAAK,SAAS,KAAK,GAAG,GAAG,KAC3D,OAAO;QAGT,OAAO;IACT;IAEA,IAAI,QAAQ,IACV,OAAO,sCAAgB,MAAM,GAAG;IAGlC,IAAI,QAAQ,GACV,OAAO;IAGT,OAAO,MAAM;AACf;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,YAAY,iCAAW,CAAC,gCAAU,OAAO,CAAC,KAAK,GAAG,EAAE;IACxD,IAAI,CAAC,WAC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S,kCAAY,IAAqB;IACxC,IAAI,KAAK,IAAI,KAAK,GAAG;QACnB,IAAI,MAAM,gCAAU,OAAO,CAAC,KAAK,GAAG;QACpC,OAAO,qCAAe,CAAC,IAAI;IAC7B;AACF","sources":["packages/@internationalized/date/src/calendars/JapaneseCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst ERA_START_DATES = [[1868, 9, 8], [1912, 7, 30], [1926, 12, 25], [1989, 1, 8], [2019, 5, 1]];\nconst ERA_END_DATES = [[1912, 7, 29], [1926, 12, 24], [1989, 1, 7], [2019, 4, 30]];\nconst ERA_ADDENDS = [1867, 1911, 1925, 1988, 2018];\nconst ERA_NAMES = ['meiji', 'taisho', 'showa', 'heisei', 'reiwa'];\n\nfunction findEraFromGregorianDate(date: AnyCalendarDate) {\n const idx = ERA_START_DATES.findIndex(([year, month, day]) => {\n if (date.year < year) {\n return true;\n }\n\n if (date.year === year && date.month < month) {\n return true;\n }\n\n if (date.year === year && date.month === month && date.day < day) {\n return true;\n }\n\n return false;\n });\n\n if (idx === -1) {\n return ERA_START_DATES.length - 1;\n }\n\n if (idx === 0) {\n return 0;\n }\n\n return idx - 1;\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let eraAddend = ERA_ADDENDS[ERA_NAMES.indexOf(date.era)];\n if (!eraAddend) {\n throw new Error('Unknown era: ' + date.era);\n }\n\n return new CalendarDate(\n date.year + eraAddend,\n date.month,\n date.day\n );\n}\n\n/**\n * The Japanese calendar is based on the Gregorian calendar, but with eras for the reign of each Japanese emperor.\n * Whenever a new emperor ascends to the throne, a new era begins and the year starts again from 1.\n * Note that eras before 1868 (Gregorian) are not currently supported by this implementation.\n */\nexport class JapaneseCalendar extends GregorianCalendar {\n identifier = 'japanese';\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let era = findEraFromGregorianDate(date);\n\n return new CalendarDate(\n this,\n ERA_NAMES[era],\n date.year - ERA_ADDENDS[era],\n date.month,\n date.day\n );\n }\n\n toJulianDay(date: AnyCalendarDate) {\n return super.toJulianDay(toGregorian(date));\n }\n\n balanceDate(date: Mutable<AnyCalendarDate>) {\n let gregorianDate = toGregorian(date);\n let era = findEraFromGregorianDate(gregorianDate);\n\n if (ERA_NAMES[era] !== date.era) {\n date.era = ERA_NAMES[era];\n date.year = gregorianDate.year - ERA_ADDENDS[era];\n }\n\n // Constrain in case we went before the first supported era.\n this.constrainDate(date);\n }\n\n constrainDate(date: Mutable<AnyCalendarDate>) {\n let idx = ERA_NAMES.indexOf(date.era);\n let end = ERA_END_DATES[idx];\n if (end != null) {\n let [endYear, endMonth, endDay] = end;\n\n // Constrain the year to the maximum possible value in the era.\n // Then constrain the month and day fields within that.\n let maxYear = endYear - ERA_ADDENDS[idx];\n date.year = Math.max(1, Math.min(maxYear, date.year));\n if (date.year === maxYear) {\n date.month = Math.min(endMonth, date.month);\n\n if (date.month === endMonth) {\n date.day = Math.min(endDay, date.day);\n }\n }\n }\n\n if (date.year === 1 && idx >= 0) {\n let [, startMonth, startDay] = ERA_START_DATES[idx];\n date.month = Math.max(startMonth, date.month);\n\n if (date.month === startMonth) {\n date.day = Math.max(startDay, date.day);\n }\n }\n }\n\n getEras() {\n return ERA_NAMES;\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n // Get the number of years in the era, taking into account the date's month and day fields.\n let era = ERA_NAMES.indexOf(date.era);\n let cur = ERA_START_DATES[era];\n let next = ERA_START_DATES[era + 1];\n if (next == null) {\n // 9999 gregorian is the maximum year allowed.\n return 9999 - cur[0] + 1;\n }\n\n let years = next[0] - cur[0];\n\n if (date.month < next[1] || (date.month === next[1] && date.day < next[2])) {\n years++;\n }\n\n return years;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getMinimumMonthInYear(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start ? start[1] : 1;\n }\n\n getMinimumDayInMonth(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start && date.month === start[1] ? start[2] : 1;\n }\n}\n\nfunction getMinimums(date: AnyCalendarDate) {\n if (date.year === 1) {\n let idx = ERA_NAMES.indexOf(date.era);\n return ERA_START_DATES[idx];\n }\n}\n"],"names":[],"version":3,"file":"JapaneseCalendar.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;AAOhG,MAAM,wCAAkB;IAAC;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAG;IAAE;QAAC;QAAM;QAAI;KAAG;IAAE;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAE;CAAC;AACjG,MAAM,sCAAgB;IAAC;QAAC;QAAM;QAAG;KAAG;IAAE;QAAC;QAAM;QAAI;KAAG;IAAE;QAAC;QAAM;QAAG;KAAE;IAAE;QAAC;QAAM;QAAG;KAAG;CAAC;AAClF,MAAM,oCAAc;IAAC;IAAM;IAAM;IAAM;IAAM;CAAK;AAClD,MAAM,kCAAY;IAAC;IAAS;IAAU;IAAS;IAAU;CAAQ;AAEjE,SAAS,+CAAyB,IAAqB;IACrD,MAAM,MAAM,sCAAgB,SAAS,CAAC,CAAC,CAAC,MAAM,OAAO,IAAI;QACv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IAAI,CAAC,EAAE,IAAI,KAAK,GAAG,GAAG,IAAI,CAAC,EAAE,EACvE;QAGF,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,sBAAsB,IAAqB,EAAU;QACnD,IAAI,QAAQ,kCAAY;QACxB,OAAO,QAAQ,KAAK,CAAC,EAAE,GAAG;IAC5B;IAEA,qBAAqB,IAAqB,EAAU;QAClD,IAAI,QAAQ,kCAAY;QACxB,OAAO,SAAS,KAAK,KAAK,KAAK,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,GAAG;IACvD;;QAjGK,qBACL,aAAiC;;AAiGnC;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,KAAK,IAAI,KAAK,GAAG;QACnB,IAAI,MAAM,gCAAU,OAAO,CAAC,KAAK,GAAG;QACpC,OAAO,qCAAe,CAAC,IAAI;IAC7B;AACF","sources":["packages/@internationalized/date/src/calendars/JapaneseCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst ERA_START_DATES = [[1868, 9, 8], [1912, 7, 30], [1926, 12, 25], [1989, 1, 8], [2019, 5, 1]];\nconst ERA_END_DATES = [[1912, 7, 29], [1926, 12, 24], [1989, 1, 7], [2019, 4, 30]];\nconst ERA_ADDENDS = [1867, 1911, 1925, 1988, 2018];\nconst ERA_NAMES = ['meiji', 'taisho', 'showa', 'heisei', 'reiwa'];\n\nfunction findEraFromGregorianDate(date: AnyCalendarDate) {\n const idx = ERA_START_DATES.findIndex(([year, month, day]) => {\n if (date.year < year) {\n return true;\n }\n\n if (date.year === year && date.month < month) {\n return true;\n }\n\n if (date.year === year && date.month === month && date.day < day) {\n return true;\n }\n\n return false;\n });\n\n if (idx === -1) {\n return ERA_START_DATES.length - 1;\n }\n\n if (idx === 0) {\n return 0;\n }\n\n return idx - 1;\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let eraAddend = ERA_ADDENDS[ERA_NAMES.indexOf(date.era)];\n if (!eraAddend) {\n throw new Error('Unknown era: ' + date.era);\n }\n\n return new CalendarDate(\n date.year + eraAddend,\n date.month,\n date.day\n );\n}\n\n/**\n * The Japanese calendar is based on the Gregorian calendar, but with eras for the reign of each Japanese emperor.\n * Whenever a new emperor ascends to the throne, a new era begins and the year starts again from 1.\n * Note that eras before 1868 (Gregorian) are not currently supported by this implementation.\n */\nexport class JapaneseCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'japanese';\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let era = findEraFromGregorianDate(date);\n\n return new CalendarDate(\n this,\n ERA_NAMES[era],\n date.year - ERA_ADDENDS[era],\n date.month,\n date.day\n );\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n balanceDate(date: Mutable<AnyCalendarDate>): void {\n let gregorianDate = toGregorian(date);\n let era = findEraFromGregorianDate(gregorianDate);\n\n if (ERA_NAMES[era] !== date.era) {\n date.era = ERA_NAMES[era];\n date.year = gregorianDate.year - ERA_ADDENDS[era];\n }\n\n // Constrain in case we went before the first supported era.\n this.constrainDate(date);\n }\n\n constrainDate(date: Mutable<AnyCalendarDate>): void {\n let idx = ERA_NAMES.indexOf(date.era);\n let end = ERA_END_DATES[idx];\n if (end != null) {\n let [endYear, endMonth, endDay] = end;\n\n // Constrain the year to the maximum possible value in the era.\n // Then constrain the month and day fields within that.\n let maxYear = endYear - ERA_ADDENDS[idx];\n date.year = Math.max(1, Math.min(maxYear, date.year));\n if (date.year === maxYear) {\n date.month = Math.min(endMonth, date.month);\n\n if (date.month === endMonth) {\n date.day = Math.min(endDay, date.day);\n }\n }\n }\n\n if (date.year === 1 && idx >= 0) {\n let [, startMonth, startDay] = ERA_START_DATES[idx];\n date.month = Math.max(startMonth, date.month);\n\n if (date.month === startMonth) {\n date.day = Math.max(startDay, date.day);\n }\n }\n }\n\n getEras(): string[] {\n return ERA_NAMES;\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n // Get the number of years in the era, taking into account the date's month and day fields.\n let era = ERA_NAMES.indexOf(date.era);\n let cur = ERA_START_DATES[era];\n let next = ERA_START_DATES[era + 1];\n if (next == null) {\n // 9999 gregorian is the maximum year allowed.\n return 9999 - cur[0] + 1;\n }\n\n let years = next[0] - cur[0];\n\n if (date.month < next[1] || (date.month === next[1] && date.day < next[2])) {\n years++;\n }\n\n return years;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getMinimumMonthInYear(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start ? start[1] : 1;\n }\n\n getMinimumDayInMonth(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start && date.month === start[1] ? start[2] : 1;\n }\n}\n\nfunction getMinimums(date: AnyCalendarDate) {\n if (date.year === 1) {\n let idx = ERA_NAMES.indexOf(date.era);\n return ERA_START_DATES[idx];\n }\n}\n"],"names":[],"version":3,"file":"JapaneseCalendar.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,sCAAgB;AAEtB,wEAAwE;AACx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A+Cf","sources":["packages/@internationalized/date/src/calendars/PersianCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod} from '../utils';\n\nconst PERSIAN_EPOCH = 1948320;\n\n// Number of days from the start of the year to the start of each month.\nconst MONTH_START = [\n 0, // Farvardin\n 31, // Ordibehesht\n 62, // Khordad\n 93, // Tir\n 124, // Mordad\n 155, // Shahrivar\n 186, // Mehr\n 216, // Aban\n 246, // Azar\n 276, // Dey\n 306, // Bahman\n 336 // Esfand\n];\n\n/**\n * The Persian calendar is the main calendar used in Iran and Afghanistan. It has 12 months\n * in each year, the first 6 of which have 31 days, and the next 5 have 30 days. The 12th month\n * has either 29 or 30 days depending on whether it is a leap year. The Persian year starts\n * around the March equinox.\n */\nexport class PersianCalendar implements Calendar {\n identifier = 'persian';\n\n fromJulianDay(jd: number): CalendarDate {\n let daysSinceEpoch = jd - PERSIAN_EPOCH;\n let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053);\n let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33);\n let dayOfYear = daysSinceEpoch - farvardin1;\n let month = dayOfYear < 216\n ? Math.floor(dayOfYear / 31)\n : Math.floor((dayOfYear - 6) / 30);\n let day = dayOfYear - MONTH_START[month] + 1;\n return new CalendarDate(this, year, month + 1, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let jd = PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33);\n jd += MONTH_START[date.month - 1];\n jd += date.day;\n return jd;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month <= 6) {\n return 31;\n }\n\n if (date.month <= 11) {\n return 30;\n }\n\n let isLeapYear = mod(25 * date.year + 11, 33) < 8;\n return isLeapYear ? 30 : 29;\n }\n\n getEras() {\n return ['AP'];\n }\n\n getYearsInEra(): number {\n // 9378-10-10 persian is 9999-12-31 gregorian.\n // Round down to 9377 to set the maximum full year.\n return 9377;\n }\n}\n"],"names":[],"version":3,"file":"PersianCalendar.main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,sCAAgB;AAEtB,wEAAwE;AACxE,MAAM,oCAAc;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAK,SAAS;CACf;AAQM,MAAM;IAGX,cAAc,EAAU,EAAgB;QACtC,IAAI,iBAAiB,KAAK;QAC1B,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC,AAAC,CAAA,KAAK,iBAAiB,CAAA,IAAK;QACtD,IAAI,aAAa,MAAO,CAAA,OAAO,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,OAAO,EAAC,IAAK;QACjE,IAAI,YAAY,iBAAiB;QACjC,IAAI,QAAQ,YAAY,MACpB,KAAK,KAAK,CAAC,YAAY,MACvB,KAAK,KAAK,CAAC,AAAC,CAAA,YAAY,CAAA,IAAK;QACjC,IAAI,MAAM,YAAY,iCAAW,CAAC,MAAM,GAAG;QAC3C,OAAO,IAAI,CAAA,GAAA,sCAAW,EAAE,IAAI,EAAE,MAAM,QAAQ,GAAG;IACjD;IAEA,YAAY,IAAqB,EAAU;QACzC,IAAI,KAAK,sCAAgB,IAAI,MAAO,CAAA,KAAK,IAAI,GAAG,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,KAAK,IAAI,GAAG,EAAC,IAAK;QACvF,MAAM,iCAAW,CAAC,KAAK,KAAK,GAAG,EAAE;QACjC,MAAM,KAAK,GAAG;QACd,OAAO;IACT;IAEA,kBAA0B;QACxB,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,KAAK,IAAI,GAChB,OAAO;QAGT,IAAI,KAAK,KAAK,IAAI,IAChB,OAAO;QAGT,IAAI,aAAa,CAAA,GAAA,6BAAE,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,MAAM;QAChD,OAAO,aAAa,KAAK;IAC3B;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAK;IACf;IAEA,gBAAwB;QACtB,8CAA8C;QAC9C,mDAAmD;QACnD,OAAO;IACT;;aA9CA,aAAiC;;AA+CnC","sources":["packages/@internationalized/date/src/calendars/PersianCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod} from '../utils';\n\nconst PERSIAN_EPOCH = 1948320;\n\n// Number of days from the start of the year to the start of each month.\nconst MONTH_START = [\n 0, // Farvardin\n 31, // Ordibehesht\n 62, // Khordad\n 93, // Tir\n 124, // Mordad\n 155, // Shahrivar\n 186, // Mehr\n 216, // Aban\n 246, // Azar\n 276, // Dey\n 306, // Bahman\n 336 // Esfand\n];\n\n/**\n * The Persian calendar is the main calendar used in Iran and Afghanistan. It has 12 months\n * in each year, the first 6 of which have 31 days, and the next 5 have 30 days. The 12th month\n * has either 29 or 30 days depending on whether it is a leap year. The Persian year starts\n * around the March equinox.\n */\nexport class PersianCalendar implements Calendar {\n identifier: CalendarIdentifier = 'persian';\n\n fromJulianDay(jd: number): CalendarDate {\n let daysSinceEpoch = jd - PERSIAN_EPOCH;\n let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053);\n let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33);\n let dayOfYear = daysSinceEpoch - farvardin1;\n let month = dayOfYear < 216\n ? Math.floor(dayOfYear / 31)\n : Math.floor((dayOfYear - 6) / 30);\n let day = dayOfYear - MONTH_START[month] + 1;\n return new CalendarDate(this, year, month + 1, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let jd = PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33);\n jd += MONTH_START[date.month - 1];\n jd += date.day;\n return jd;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month <= 6) {\n return 31;\n }\n\n if (date.month <= 11) {\n return 30;\n }\n\n let isLeapYear = mod(25 * date.year + 11, 33) < 8;\n return isLeapYear ? 30 : 29;\n }\n\n getEras(): string[] {\n return ['AP'];\n }\n\n getYearsInEra(): number {\n // 9378-10-10 persian is 9999-12-31 gregorian.\n // Round down to 9377 to set the maximum full year.\n return 9377;\n }\n}\n"],"names":[],"version":3,"file":"PersianCalendar.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,sCAAgB;AAEtB,wEAAwE;AACxE,MAAM,oCAAc;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAC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right 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod} from '../utils';\n\nconst PERSIAN_EPOCH = 1948320;\n\n// Number of days from the start of the year to the start of each month.\nconst MONTH_START = [\n 0, // Farvardin\n 31, // Ordibehesht\n 62, // Khordad\n 93, // Tir\n 124, // Mordad\n 155, // Shahrivar\n 186, // Mehr\n 216, // Aban\n 246, // Azar\n 276, // Dey\n 306, // Bahman\n 336 // Esfand\n];\n\n/**\n * The Persian calendar is the main calendar used in Iran and Afghanistan. It has 12 months\n * in each year, the first 6 of which have 31 days, and the next 5 have 30 days. The 12th month\n * has either 29 or 30 days depending on whether it is a leap year. The Persian year starts\n * around the March equinox.\n */\nexport class PersianCalendar implements Calendar {\n identifier = 'persian';\n\n fromJulianDay(jd: number): CalendarDate {\n let daysSinceEpoch = jd - PERSIAN_EPOCH;\n let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053);\n let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33);\n let dayOfYear = daysSinceEpoch - farvardin1;\n let month = dayOfYear < 216\n ? Math.floor(dayOfYear / 31)\n : Math.floor((dayOfYear - 6) / 30);\n let day = dayOfYear - MONTH_START[month] + 1;\n return new CalendarDate(this, year, month + 1, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let jd = PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33);\n jd += MONTH_START[date.month - 1];\n jd += date.day;\n return jd;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month <= 6) {\n return 31;\n }\n\n if (date.month <= 11) {\n return 30;\n }\n\n let isLeapYear = mod(25 * date.year + 11, 33) < 8;\n return isLeapYear ? 30 : 29;\n }\n\n getEras() {\n return ['AP'];\n }\n\n getYearsInEra(): number {\n // 9378-10-10 persian is 9999-12-31 gregorian.\n // Round down to 9377 to set the maximum full year.\n return 9377;\n }\n}\n"],"names":[],"version":3,"file":"PersianCalendar.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,sCAAgB;AAEtB,wEAAwE;AACxE,MAAM,oCAAc;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAK,SAAS;CACf;AAQM,MAAM;IAGX,cAAc,EAAU,EAAgB;QACtC,IAAI,iBAAiB,KAAK;QAC1B,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC,AAAC,CAAA,KAAK,iBAAiB,CAAA,IAAK;QACtD,IAAI,aAAa,MAAO,CAAA,OAAO,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,OAAO,EAAC,IAAK;QACjE,IAAI,YAAY,iBAAiB;QACjC,IAAI,QAAQ,YAAY,MACpB,KAAK,KAAK,CAAC,YAAY,MACvB,KAAK,KAAK,CAAC,AAAC,CAAA,YAAY,CAAA,IAAK;QACjC,IAAI,MAAM,YAAY,iCAAW,CAAC,MAAM,GAAG;QAC3C,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,IAAI,EAAE,MAAM,QAAQ,GAAG;IACjD;IAEA,YAAY,IAAqB,EAAU;QACzC,IAAI,KAAK,sCAAgB,IAAI,MAAO,CAAA,KAAK,IAAI,GAAG,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,KAAK,IAAI,GAAG,EAAC,IAAK;QACvF,MAAM,iCAAW,CAAC,KAAK,KAAK,GAAG,EAAE;QACjC,MAAM,KAAK,GAAG;QACd,OAAO;IACT;IAEA,kBAA0B;QACxB,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,KAAK,IAAI,GAChB,OAAO;QAGT,IAAI,KAAK,KAAK,IAAI,IAChB,OAAO;QAGT,IAAI,aAAa,CAAA,GAAA,yCAAE,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,MAAM;QAChD,OAAO,aAAa,KAAK;IAC3B;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAK;IACf;IAEA,gBAAwB;QACtB,8CAA8C;QAC9C,mDAAmD;QACnD,OAAO;IACT;;aA9CA,aAAiC;;AA+CnC","sources":["packages/@internationalized/date/src/calendars/PersianCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod} from '../utils';\n\nconst PERSIAN_EPOCH = 1948320;\n\n// Number of days from the start of the year to the start of each month.\nconst MONTH_START = [\n 0, // Farvardin\n 31, // Ordibehesht\n 62, // Khordad\n 93, // Tir\n 124, // Mordad\n 155, // Shahrivar\n 186, // Mehr\n 216, // Aban\n 246, // Azar\n 276, // Dey\n 306, // Bahman\n 336 // Esfand\n];\n\n/**\n * The Persian calendar is the main calendar used in Iran and Afghanistan. It has 12 months\n * in each year, the first 6 of which have 31 days, and the next 5 have 30 days. The 12th month\n * has either 29 or 30 days depending on whether it is a leap year. The Persian year starts\n * around the March equinox.\n */\nexport class PersianCalendar implements Calendar {\n identifier: CalendarIdentifier = 'persian';\n\n fromJulianDay(jd: number): CalendarDate {\n let daysSinceEpoch = jd - PERSIAN_EPOCH;\n let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053);\n let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33);\n let dayOfYear = daysSinceEpoch - farvardin1;\n let month = dayOfYear < 216\n ? Math.floor(dayOfYear / 31)\n : Math.floor((dayOfYear - 6) / 30);\n let day = dayOfYear - MONTH_START[month] + 1;\n return new CalendarDate(this, year, month + 1, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let jd = PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33);\n jd += MONTH_START[date.month - 1];\n jd += date.day;\n return jd;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month <= 6) {\n return 31;\n }\n\n if (date.month <= 11) {\n return 30;\n }\n\n let isLeapYear = mod(25 * date.year + 11, 33) < 8;\n return isLeapYear ? 30 : 29;\n }\n\n getEras(): string[] {\n return ['AP'];\n }\n\n getYearsInEra(): number {\n // 9378-10-10 persian is 9999-12-31 gregorian.\n // Round down to 9377 to set the maximum full year.\n return 9377;\n }\n}\n"],"names":[],"version":3,"file":"PersianCalendar.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAOhG,MAAM,yCAAmB;AAEzB,SAAS,oCAAc,IAAqB;IAC1C,OAAO,KAAK,GAAG,KAAK,WAChB,KAAK,IAAI,GAAG,yCACZ,IAAI,KAAK,IAAI,GAAG;AACtB;AAEA,SAAS,wCAAkB,IAAY;IACrC,IAAI,IAAI,OAAO;IACf,IAAI,IAAI,GACN,OAAO;QAAC;QAAU;KAAE;SAEpB,OAAO;QAAC;QAAiB,IAAI;KAAE;AAEnC;AAOO,MAAM,kDAAuB,CAAA,GAAA,2CAAgB;IAGlD,cAAc,EAAU,EAAgB;QACtC,IAAI,OAAO,KAAK,CAAC,cAAc;QAC/B,IAAI,eAAe,CAAA,GAAA,yCAAc,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI;QACtD,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB;QACpC,OAAO,IAAI,CAAA,GAAA,sCAAW,EAAE,IAAI,EAAE,KAAK,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG;IAC/D;IAEA,YAAY,IAAqB,EAAE;QACjC,OAAO,KAAK,CAAC,YAAY,kCAAY;IACvC;IAEA,UAAU;QACR,OAAO;YAAC;YAAiB;SAAS;IACpC;IAEA,YAAY,IAA8B,EAAE;QAC1C,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB,oCAAc;QAClD,KAAK,GAAG,GAAG;QACX,KAAK,IAAI,GAAG;IACd;IAEA,aAAa,IAAqB,EAAW;QAC3C,OAAO,KAAK,GAAG,KAAK;IACtB;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,cAAc,IAAqB,EAAU;QAC3C,OAAO,KAAK,GAAG,KAAK,kBAAkB,OAAO,OAAO;IACtD;;6BAjCA,aAAa,MAAO,oBAAoB;;;AAkC1C;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAA,GAAA,0CAAe,EAAE,oCAAc;IACjD,OAAO,IAAI,CAAA,GAAA,sCAAW,EACpB,KACA,MACA,KAAK,KAAK,EACV,KAAK,GAAG;AAEZ","sources":["packages/@internationalized/date/src/calendars/TaiwanCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {fromExtendedYear, getExtendedYear, GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst TAIWAN_ERA_START = 1911;\n\nfunction gregorianYear(date: AnyCalendarDate) {\n return date.era === 'minguo'\n ? date.year + TAIWAN_ERA_START\n : 1 - date.year + TAIWAN_ERA_START;\n}\n\nfunction gregorianToTaiwan(year: number): [string, number] {\n let y = year - TAIWAN_ERA_START;\n if (y > 0) {\n return ['minguo', y];\n } else {\n return ['before_minguo', 1 - y];\n }\n}\n\n/**\n * The Taiwanese calendar is the same as the Gregorian calendar, but years\n * are numbered starting from 1912 (Gregorian). Two eras are supported:\n * 'before_minguo' and 'minguo'.\n */\nexport class TaiwanCalendar extends GregorianCalendar {\n identifier = 'roc'; // Republic of China\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let extendedYear = getExtendedYear(date.era, date.year);\n let [era, year] = gregorianToTaiwan(extendedYear);\n return new CalendarDate(this, era, year, date.month, date.day);\n }\n\n toJulianDay(date: AnyCalendarDate) {\n return super.toJulianDay(toGregorian(date));\n }\n\n getEras() {\n return ['before_minguo', 'minguo'];\n }\n\n balanceDate(date: Mutable<AnyCalendarDate>) {\n let [era, year] = gregorianToTaiwan(gregorianYear(date));\n date.era = era;\n date.year = year;\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'before_minguo';\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n return date.era === 'before_minguo' ? 9999 : 9999 - TAIWAN_ERA_START;\n }\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let [era, year] = fromExtendedYear(gregorianYear(date));\n return new CalendarDate(\n era,\n year,\n date.month,\n date.day\n );\n}\n"],"names":[],"version":3,"file":"TaiwanCalendar.main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAOhG,MAAM,yCAAmB;AAEzB,SAAS,oCAAc,IAAqB;IAC1C,OAAO,KAAK,GAAG,KAAK,WAChB,KAAK,IAAI,GAAG,yCACZ,IAAI,KAAK,IAAI,GAAG;AACtB;AAEA,SAAS,wCAAkB,IAAY;IACrC,IAAI,IAAI,OAAO;IACf,IAAI,IAAI,GACN,OAAO;QAAC;QAAU;KAAE;SAEpB,OAAO;QAAC;QAAiB,IAAI;KAAE;AAEnC;AAOO,MAAM,kDAAuB,CAAA,GAAA,2CAAgB;IAGlD,cAAc,EAAU,EAAgB;QACtC,IAAI,OAAO,KAAK,CAAC,cAAc;QAC/B,IAAI,eAAe,CAAA,GAAA,yCAAc,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI;QACtD,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB;QACpC,OAAO,IAAI,CAAA,GAAA,sCAAW,EAAE,IAAI,EAAE,KAAK,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG;IAC/D;IAEA,YAAY,IAAqB,EAAU;QACzC,OAAO,KAAK,CAAC,YAAY,kCAAY;IACvC;IAEA,UAAoB;QAClB,OAAO;YAAC;YAAiB;SAAS;IACpC;IAEA,YAAY,IAA8B,EAAQ;QAChD,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB,oCAAc;QAClD,KAAK,GAAG,GAAG;QACX,KAAK,IAAI,GAAG;IACd;IAEA,aAAa,IAAqB,EAAW;QAC3C,OAAO,KAAK,GAAG,KAAK;IACtB;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,cAAc,IAAqB,EAAU;QAC3C,OAAO,KAAK,GAAG,KAAK,kBAAkB,OAAO,OAAO;IACtD;;QAlCK,qBACL,aAAiC,MAAO,oBAAoB;;;AAkC9D;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAA,GAAA,0CAAe,EAAE,oCAAc;IACjD,OAAO,IAAI,CAAA,GAAA,sCAAW,EACpB,KACA,MACA,KAAK,KAAK,EACV,KAAK,GAAG;AAEZ","sources":["packages/@internationalized/date/src/calendars/TaiwanCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {fromExtendedYear, getExtendedYear, GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst TAIWAN_ERA_START = 1911;\n\nfunction gregorianYear(date: AnyCalendarDate) {\n return date.era === 'minguo'\n ? date.year + TAIWAN_ERA_START\n : 1 - date.year + TAIWAN_ERA_START;\n}\n\nfunction gregorianToTaiwan(year: number): [string, number] {\n let y = year - TAIWAN_ERA_START;\n if (y > 0) {\n return ['minguo', y];\n } else {\n return ['before_minguo', 1 - y];\n }\n}\n\n/**\n * The Taiwanese calendar is the same as the Gregorian calendar, but years\n * are numbered starting from 1912 (Gregorian). Two eras are supported:\n * 'before_minguo' and 'minguo'.\n */\nexport class TaiwanCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'roc'; // Republic of China\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let extendedYear = getExtendedYear(date.era, date.year);\n let [era, year] = gregorianToTaiwan(extendedYear);\n return new CalendarDate(this, era, year, date.month, date.day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n getEras(): string[] {\n return ['before_minguo', 'minguo'];\n }\n\n balanceDate(date: Mutable<AnyCalendarDate>): void {\n let [era, year] = gregorianToTaiwan(gregorianYear(date));\n date.era = era;\n date.year = year;\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'before_minguo';\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n return date.era === 'before_minguo' ? 9999 : 9999 - TAIWAN_ERA_START;\n }\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let [era, year] = fromExtendedYear(gregorianYear(date));\n return new CalendarDate(\n era,\n year,\n date.month,\n date.day\n );\n}\n"],"names":[],"version":3,"file":"TaiwanCalendar.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAOhG,MAAM,yCAAmB;AAEzB,SAAS,oCAAc,IAAqB;IAC1C,OAAO,KAAK,GAAG,KAAK,WAChB,KAAK,IAAI,GAAG,yCACZ,IAAI,KAAK,IAAI,GAAG;AACtB;AAEA,SAAS,wCAAkB,IAAY;IACrC,IAAI,IAAI,OAAO;IACf,IAAI,IAAI,GACN,OAAO;QAAC;QAAU;KAAE;SAEpB,OAAO;QAAC;QAAiB,IAAI;KAAE;AAEnC;AAOO,MAAM,kDAAuB,CAAA,GAAA,yCAAgB;IAGlD,cAAc,EAAU,EAAgB;QACtC,IAAI,OAAO,KAAK,CAAC,cAAc;QAC/B,IAAI,eAAe,CAAA,GAAA,yCAAc,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI;QACtD,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB;QACpC,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,IAAI,EAAE,KAAK,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG;IAC/D;IAEA,YAAY,IAAqB,EAAE;QACjC,OAAO,KAAK,CAAC,YAAY,kCAAY;IACvC;IAEA,UAAU;QACR,OAAO;YAAC;YAAiB;SAAS;IACpC;IAEA,YAAY,IAA8B,EAAE;QAC1C,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB,oCAAc;QAClD,KAAK,GAAG,GAAG;QACX,KAAK,IAAI,GAAG;IACd;IAEA,aAAa,IAAqB,EAAW;QAC3C,OAAO,KAAK,GAAG,KAAK;IACtB;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,cAAc,IAAqB,EAAU;QAC3C,OAAO,KAAK,GAAG,KAAK,kBAAkB,OAAO,OAAO;IACtD;;6BAjCA,aAAa,MAAO,oBAAoB;;;AAkC1C;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAA,GAAA,yCAAe,EAAE,oCAAc;IACjD,OAAO,IAAI,CAAA,GAAA,yCAAW,EACpB,KACA,MACA,KAAK,KAAK,EACV,KAAK,GAAG;AAEZ","sources":["packages/@internationalized/date/src/calendars/TaiwanCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {fromExtendedYear, getExtendedYear, GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst TAIWAN_ERA_START = 1911;\n\nfunction gregorianYear(date: AnyCalendarDate) {\n return date.era === 'minguo'\n ? date.year + TAIWAN_ERA_START\n : 1 - date.year + TAIWAN_ERA_START;\n}\n\nfunction gregorianToTaiwan(year: number): [string, number] {\n let y = year - TAIWAN_ERA_START;\n if (y > 0) {\n return ['minguo', y];\n } else {\n return ['before_minguo', 1 - y];\n }\n}\n\n/**\n * The Taiwanese calendar is the same as the Gregorian calendar, but years\n * are numbered starting from 1912 (Gregorian). Two eras are supported:\n * 'before_minguo' and 'minguo'.\n */\nexport class TaiwanCalendar extends GregorianCalendar {\n identifier = 'roc'; // Republic of China\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let extendedYear = getExtendedYear(date.era, date.year);\n let [era, year] = gregorianToTaiwan(extendedYear);\n return new CalendarDate(this, era, year, date.month, date.day);\n }\n\n toJulianDay(date: AnyCalendarDate) {\n return super.toJulianDay(toGregorian(date));\n }\n\n getEras() {\n return ['before_minguo', 'minguo'];\n }\n\n balanceDate(date: Mutable<AnyCalendarDate>) {\n let [era, year] = gregorianToTaiwan(gregorianYear(date));\n date.era = era;\n date.year = year;\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'before_minguo';\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n return date.era === 'before_minguo' ? 9999 : 9999 - TAIWAN_ERA_START;\n }\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let [era, year] = fromExtendedYear(gregorianYear(date));\n return new CalendarDate(\n era,\n year,\n date.month,\n date.day\n );\n}\n"],"names":[],"version":3,"file":"TaiwanCalendar.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAOhG,MAAM,yCAAmB;AAEzB,SAAS,oCAAc,IAAqB;IAC1C,OAAO,KAAK,GAAG,KAAK,WAChB,KAAK,IAAI,GAAG,yCACZ,IAAI,KAAK,IAAI,GAAG;AACtB;AAEA,SAAS,wCAAkB,IAAY;IACrC,IAAI,IAAI,OAAO;IACf,IAAI,IAAI,GACN,OAAO;QAAC;QAAU;KAAE;SAEpB,OAAO;QAAC;QAAiB,IAAI;KAAE;AAEnC;AAOO,MAAM,kDAAuB,CAAA,GAAA,yCAAgB;IAGlD,cAAc,EAAU,EAAgB;QACtC,IAAI,OAAO,KAAK,CAAC,cAAc;QAC/B,IAAI,eAAe,CAAA,GAAA,yCAAc,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI;QACtD,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB;QACpC,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,IAAI,EAAE,KAAK,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG;IAC/D;IAEA,YAAY,IAAqB,EAAU;QACzC,OAAO,KAAK,CAAC,YAAY,kCAAY;IACvC;IAEA,UAAoB;QAClB,OAAO;YAAC;YAAiB;SAAS;IACpC;IAEA,YAAY,IAA8B,EAAQ;QAChD,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB,oCAAc;QAClD,KAAK,GAAG,GAAG;QACX,KAAK,IAAI,GAAG;IACd;IAEA,aAAa,IAAqB,EAAW;QAC3C,OAAO,KAAK,GAAG,KAAK;IACtB;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,cAAc,IAAqB,EAAU;QAC3C,OAAO,KAAK,GAAG,KAAK,kBAAkB,OAAO,OAAO;IACtD;;QAlCK,qBACL,aAAiC,MAAO,oBAAoB;;;AAkC9D;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAA,GAAA,yCAAe,EAAE,oCAAc;IACjD,OAAO,IAAI,CAAA,GAAA,yCAAW,EACpB,KACA,MACA,KAAK,KAAK,EACV,KAAK,GAAG;AAEZ","sources":["packages/@internationalized/date/src/calendars/TaiwanCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {fromExtendedYear, getExtendedYear, GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst TAIWAN_ERA_START = 1911;\n\nfunction gregorianYear(date: AnyCalendarDate) {\n return date.era === 'minguo'\n ? date.year + TAIWAN_ERA_START\n : 1 - date.year + TAIWAN_ERA_START;\n}\n\nfunction gregorianToTaiwan(year: number): [string, number] {\n let y = year - TAIWAN_ERA_START;\n if (y > 0) {\n return ['minguo', y];\n } else {\n return ['before_minguo', 1 - y];\n }\n}\n\n/**\n * The Taiwanese calendar is the same as the Gregorian calendar, but years\n * are numbered starting from 1912 (Gregorian). Two eras are supported:\n * 'before_minguo' and 'minguo'.\n */\nexport class TaiwanCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'roc'; // Republic of China\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let extendedYear = getExtendedYear(date.era, date.year);\n let [era, year] = gregorianToTaiwan(extendedYear);\n return new CalendarDate(this, era, year, date.month, date.day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n getEras(): string[] {\n return ['before_minguo', 'minguo'];\n }\n\n balanceDate(date: Mutable<AnyCalendarDate>): void {\n let [era, year] = gregorianToTaiwan(gregorianYear(date));\n date.era = era;\n date.year = year;\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'before_minguo';\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n return date.era === 'before_minguo' ? 9999 : 9999 - TAIWAN_ERA_START;\n }\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let [era, year] = fromExtendedYear(gregorianYear(date));\n return new CalendarDate(\n era,\n year,\n date.month,\n date.day\n );\n}\n"],"names":[],"version":3,"file":"TaiwanCalendar.module.js.map"}
@@ -201,7 +201,7 @@ function $4ae0260a69729f1d$export$d33f79e3ffc3dc83(dateTime) {
201
201
  return new (0, $625ad1e1f4c43bc1$exports.Time)(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);
202
202
  }
203
203
  function $4ae0260a69729f1d$export$b4a036af3fc0b032(date, calendar) {
204
- if (date.calendar.identifier === calendar.identifier) return date;
204
+ if ((0, $1f0f7ebf1ae6c530$exports.isEqualCalendar)(date.calendar, calendar)) return date;
205
205
  let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));
206
206
  let copy = date.copy();
207
207
  copy.calendar = calendar;
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;;;AASzF,SAAS,yCAAc,IAAiB;IAC7C,OAAO,0CAAW,MAAM,IA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W,MAAM,UAAU;IACpC,OAAO,0CAAa,IAAI;AAC1B;AAEO,SAAS,yCAAY,IAAmB;IAC7C,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,IAAI,KAAK;AAClB;AAGO,SAAS,0CAAW,IAAmB,EAAE,QAAgB;IAC9D,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,0CAAW,0CAAa,IAAI,WAAW,KAAK,QAAQ;AAC7D;AAGO,SAAS,0CAAgB,IAAmB;IACjD,OAAO,0CAAW,MAAM,CAAA,GAAA,0CAAe;AACzC","sources":["packages/@internationalized/date/src/conversion.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, AnyDateTime, AnyTime, Calendar, DateFields, Disambiguation, TimeFields} from './types';\nimport {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from './CalendarDate';\nimport {constrain} from './manipulation';\nimport {getExtendedYear, GregorianCalendar} from './calendars/GregorianCalendar';\nimport {getLocalTimeZone} from './queries';\nimport {Mutable} from './utils';\n\nexport function epochFromDate(date: AnyDateTime) {\n date = toCalendar(date, new GregorianCalendar());\n let year = getExtendedYear(date.era, date.year);\n return epochFromParts(year, date.month, date.day, date.hour, date.minute, date.second, date.millisecond);\n}\n\nfunction epochFromParts(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number) {\n // Note: Date.UTC() interprets one and two-digit years as being in the\n // 20th century, so don't use it\n let date = new Date();\n date.setUTCHours(hour, minute, second, millisecond);\n date.setUTCFullYear(year, month - 1, day);\n return date.getTime();\n}\n\nexport function getTimeZoneOffset(ms: number, timeZone: string) {\n // Fast path for UTC.\n if (timeZone === 'UTC') {\n return 0;\n }\n\n // Fast path: for local timezone after 1970, use native Date.\n if (ms > 0 && timeZone === getLocalTimeZone()) {\n return new Date(ms).getTimezoneOffset() * -60 * 1000;\n }\n\n let {year, month, day, hour, minute, second} = getTimeZoneParts(ms, timeZone);\n let utc = epochFromParts(year, month, day, hour, minute, second, 0);\n return utc - Math.floor(ms / 1000) * 1000;\n}\n\nconst formattersByTimeZone = new Map<string, Intl.DateTimeFormat>();\n\nfunction getTimeZoneParts(ms: number, timeZone: string) {\n let formatter = formattersByTimeZone.get(timeZone);\n if (!formatter) {\n formatter = new Intl.DateTimeFormat('en-US', {\n timeZone,\n hour12: false,\n era: 'short',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric'\n });\n\n formattersByTimeZone.set(timeZone, formatter);\n }\n\n let parts = formatter.formatToParts(new Date(ms));\n let namedParts: {[name: string]: string} = {};\n for (let part of parts) {\n if (part.type !== 'literal') {\n namedParts[part.type] = part.value;\n }\n }\n\n\n return {\n // Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253\n year: namedParts.era === 'BC' || namedParts.era === 'B' ? -namedParts.year + 1 : +namedParts.year,\n month: +namedParts.month,\n day: +namedParts.day,\n hour: namedParts.hour === '24' ? 0 : +namedParts.hour, // bugs.chromium.org/p/chromium/issues/detail?id=1045791\n minute: +namedParts.minute,\n second: +namedParts.second\n };\n}\n\nconst DAYMILLIS = 86400000;\n\nexport function possibleAbsolutes(date: CalendarDateTime, timeZone: string): number[] {\n let ms = epochFromDate(date);\n let earlier = ms - getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let later = ms - getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n return getValidWallTimes(date, timeZone, earlier, later);\n}\n\nfunction getValidWallTimes(date: CalendarDateTime, timeZone: string, earlier: number, later: number): number[] {\n let found = earlier === later ? [earlier] : [earlier, later];\n return found.filter(absolute => isValidWallTime(date, timeZone, absolute));\n}\n\nfunction isValidWallTime(date: CalendarDateTime, timeZone: string, absolute: number) {\n let parts = getTimeZoneParts(absolute, timeZone);\n return date.year === parts.year\n && date.month === parts.month\n && date.day === parts.day\n && date.hour === parts.hour\n && date.minute === parts.minute\n && date.second === parts.second;\n}\n\nexport function toAbsolute(date: CalendarDate | CalendarDateTime, timeZone: string, disambiguation: Disambiguation = 'compatible'): number {\n let dateTime = toCalendarDateTime(date);\n\n // Fast path: if the time zone is UTC, use native Date.\n if (timeZone === 'UTC') {\n return epochFromDate(dateTime);\n }\n\n // Fast path: if the time zone is the local timezone and disambiguation is compatible, use native Date.\n if (timeZone === getLocalTimeZone() && disambiguation === 'compatible') {\n dateTime = toCalendar(dateTime, new GregorianCalendar());\n\n // Don't use Date constructor here because two-digit years are interpreted in the 20th century.\n let date = new Date();\n let year = getExtendedYear(dateTime.era, dateTime.year);\n date.setFullYear(year, dateTime.month - 1, dateTime.day);\n date.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n return date.getTime();\n }\n\n let ms = epochFromDate(dateTime);\n let offsetBefore = getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let offsetAfter = getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n let valid = getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter);\n\n if (valid.length === 1) {\n return valid[0];\n }\n\n if (valid.length > 1) {\n switch (disambiguation) {\n // 'compatible' means 'earlier' for \"fall back\" transitions\n case 'compatible':\n case 'earlier':\n return valid[0];\n case 'later':\n return valid[valid.length - 1];\n case 'reject':\n throw new RangeError('Multiple possible absolute times found');\n }\n }\n\n switch (disambiguation) {\n case 'earlier':\n return Math.min(ms - offsetBefore, ms - offsetAfter);\n // 'compatible' means 'later' for \"spring forward\" transitions\n case 'compatible':\n case 'later':\n return Math.max(ms - offsetBefore, ms - offsetAfter);\n case 'reject':\n throw new RangeError('No such absolute time found');\n }\n}\n\nexport function toDate(dateTime: CalendarDate | CalendarDateTime, timeZone: string, disambiguation: Disambiguation = 'compatible'): Date {\n return new Date(toAbsolute(dateTime, timeZone, disambiguation));\n}\n\n/**\n * Takes a Unix epoch (milliseconds since 1970) and converts it to the provided time zone.\n */\nexport function fromAbsolute(ms: number, timeZone: string): ZonedDateTime {\n let offset = getTimeZoneOffset(ms, timeZone);\n let date = new Date(ms + offset);\n let year = date.getUTCFullYear();\n let month = date.getUTCMonth() + 1;\n let day = date.getUTCDate();\n let hour = date.getUTCHours();\n let minute = date.getUTCMinutes();\n let second = date.getUTCSeconds();\n let millisecond = date.getUTCMilliseconds();\n\n return new ZonedDateTime(year < 1 ? 'BC' : 'AD', year < 1 ? -year + 1 : year, month, day, timeZone, offset, hour, minute, second, millisecond);\n}\n\n/**\n * Takes a `Date` object and converts it to the provided time zone.\n */\nexport function fromDate(date: Date, timeZone: string): ZonedDateTime {\n return fromAbsolute(date.getTime(), timeZone);\n}\n\nexport function fromDateToLocal(date: Date): ZonedDateTime {\n return fromDate(date, getLocalTimeZone());\n}\n\n/** Converts a value with date components such as a `CalendarDateTime` or `ZonedDateTime` into a `CalendarDate`. */\nexport function toCalendarDate(dateTime: AnyCalendarDate): CalendarDate {\n return new CalendarDate(dateTime.calendar, dateTime.era, dateTime.year, dateTime.month, dateTime.day);\n}\n\nexport function toDateFields(date: AnyCalendarDate): DateFields {\n return {\n era: date.era,\n year: date.year,\n month: date.month,\n day: date.day\n };\n}\n\nexport function toTimeFields(date: AnyTime): TimeFields {\n return {\n hour: date.hour,\n minute: date.minute,\n second: date.second,\n millisecond: date.millisecond\n };\n}\n\n/**\n * Converts a date value to a `CalendarDateTime`. An optional `Time` value can be passed to set the time\n * of the resulting value, otherwise it will default to midnight.\n */\nexport function toCalendarDateTime(date: CalendarDate | CalendarDateTime | ZonedDateTime, time?: AnyTime): CalendarDateTime {\n let hour = 0, minute = 0, second = 0, millisecond = 0;\n if ('timeZone' in date) {\n ({hour, minute, second, millisecond} = date);\n } else if ('hour' in date && !time) {\n return date;\n }\n\n if (time) {\n ({hour, minute, second, millisecond} = time);\n }\n\n return new CalendarDateTime(\n date.calendar,\n date.era,\n date.year,\n date.month,\n date.day,\n hour,\n minute,\n second,\n millisecond\n );\n}\n\n/** Extracts the time components from a value containing a date and time. */\nexport function toTime(dateTime: CalendarDateTime | ZonedDateTime): Time {\n return new Time(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n}\n\n/** Converts a date from one calendar system to another. */\nexport function toCalendar<T extends AnyCalendarDate>(date: T, calendar: Calendar): T {\n if (date.calendar.identifier === calendar.identifier) {\n return date;\n }\n\n let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));\n let copy: Mutable<T> = date.copy();\n copy.calendar = calendar;\n copy.era = calendarDate.era;\n copy.year = calendarDate.year;\n copy.month = calendarDate.month;\n copy.day = calendarDate.day;\n constrain(copy);\n return copy;\n}\n\n/**\n * Converts a date value to a `ZonedDateTime` in the provided time zone. The `disambiguation` option can be set\n * to control how values that fall on daylight saving time changes are interpreted.\n */\nexport function toZoned(date: CalendarDate | CalendarDateTime | ZonedDateTime, timeZone: string, disambiguation?: Disambiguation): ZonedDateTime {\n if (date instanceof ZonedDateTime) {\n if (date.timeZone === timeZone) {\n return date;\n }\n\n return toTimeZone(date, timeZone);\n }\n\n let ms = toAbsolute(date, timeZone, disambiguation);\n return fromAbsolute(ms, timeZone);\n}\n\nexport function zonedToDate(date: ZonedDateTime) {\n let ms = epochFromDate(date) - date.offset;\n return new Date(ms);\n}\n\n/** Converts a `ZonedDateTime` from one time zone to another. */\nexport function toTimeZone(date: ZonedDateTime, timeZone: string): ZonedDateTime {\n let ms = epochFromDate(date) - date.offset;\n return toCalendar(fromAbsolute(ms, timeZone), date.calendar);\n}\n\n/** Converts the given `ZonedDateTime` into the user's local time zone. */\nexport function toLocalTimeZone(date: ZonedDateTime): ZonedDateTime {\n return toTimeZone(date, getLocalTimeZone());\n}\n"],"names":[],"version":3,"file":"conversion.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;;;AASzF,SAAS,yCAAc,IAAiB;IAC7C,OAAO,0CAAW,MAAM,IAAI,CAAA,GAAA,2CAAgB;IAC5C,IAAI,OAAO,CAAA,GAAA,yCAAc,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI;IAC9C,OAAO,qCAAe,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW;AACzG;AAEA,SAAS,qCAAe,IAAY,EAAE,KAAa,EAAE,GAAW,EAAE,IAAY,EAAE,MAAc,EAAE,MAAc,EAAE,WAAmB;IACjI,sEAAsE;IACtE,gCAAgC;IAChC,IAAI,OAAO,IAAI;IACf,KAAK,WAAW,CAAC,MAAM,QAAQ,QAAQ;IACvC,KAAK,cAAc,CAAC,MAAM,QAAQ,GAAG;IACrC,OAAO,KAAK,OAAO;AACrB;AAEO,SAAS,0CAAkB,EAAU,EAAE,QAAgB;IAC5D,qBAAqB;IACrB,IAAI,aAAa,OACf,OAAO;IAGT,6DAA6D;IAC7D,IAAI,KAAK,KAAK,aAAa,CAAA,GAAA,0CAAe,KACxC,OAAO,IAAI,KAAK,IAAI,iBAAiB,KAA9B;IAGT,IAAI,QAAC,IAAI,SAAE,KAAK,OAAE,GAAG,QAAE,IAAI,UAAE,MAAM,UAAE,MAAM,EAAC,GAAG,uCAAiB,IAAI;IACpE,IAAI,MAAM,qCAAe,MAAM,OAAO,KAAK,MAAM,QAAQ,QAAQ;IACjE,OAAO,MAAM,KAAK,KAAK,CAAC,KAAK,QAAQ;AACvC;AAEA,MAAM,6CAAuB,IAA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/B,KAAK,GAAG,GAAG,aAAa,GAAG;IAC3B,CAAA,GAAA,mCAAQ,EAAE;IACV,OAAO;AACT;AAMO,SAAS,0CAAQ,IAAqD,EAAE,QAAgB,EAAE,cAA+B;IAC9H,IAAI,gBAAgB,CAAA,GAAA,uCAAY,GAAG;QACjC,IAAI,KAAK,QAAQ,KAAK,UACpB,OAAO;QAGT,OAAO,0CAAW,MAAM;IAC1B;IAEA,IAAI,KAAK,0CAAW,MAAM,UAAU;IACpC,OAAO,0CAAa,IAAI;AAC1B;AAEO,SAAS,yCAAY,IAAmB;IAC7C,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,IAAI,KAAK;AAClB;AAGO,SAAS,0CAAW,IAAmB,EAAE,QAAgB;IAC9D,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,0CAAW,0CAAa,IAAI,WAAW,KAAK,QAAQ;AAC7D;AAGO,SAAS,0CAAgB,IAAmB;IACjD,OAAO,0CAAW,MAAM,CAAA,GAAA,0CAAe;AACzC","sources":["packages/@internationalized/date/src/conversion.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, AnyDateTime, AnyTime, Calendar, DateFields, Disambiguation, TimeFields} from './types';\nimport {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from './CalendarDate';\nimport {constrain} from './manipulation';\nimport {getExtendedYear, GregorianCalendar} from './calendars/GregorianCalendar';\nimport {getLocalTimeZone, isEqualCalendar} from './queries';\nimport {Mutable} from './utils';\n\nexport function epochFromDate(date: AnyDateTime): number {\n date = toCalendar(date, new GregorianCalendar());\n let year = getExtendedYear(date.era, date.year);\n return epochFromParts(year, date.month, date.day, date.hour, date.minute, date.second, date.millisecond);\n}\n\nfunction epochFromParts(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number): number {\n // Note: Date.UTC() interprets one and two-digit years as being in the\n // 20th century, so don't use it\n let date = new Date();\n date.setUTCHours(hour, minute, second, millisecond);\n date.setUTCFullYear(year, month - 1, day);\n return date.getTime();\n}\n\nexport function getTimeZoneOffset(ms: number, timeZone: string): number {\n // Fast path for UTC.\n if (timeZone === 'UTC') {\n return 0;\n }\n\n // Fast path: for local timezone after 1970, use native Date.\n if (ms > 0 && timeZone === getLocalTimeZone()) {\n return new Date(ms).getTimezoneOffset() * -60 * 1000;\n }\n\n let {year, month, day, hour, minute, second} = getTimeZoneParts(ms, timeZone);\n let utc = epochFromParts(year, month, day, hour, minute, second, 0);\n return utc - Math.floor(ms / 1000) * 1000;\n}\n\nconst formattersByTimeZone = new Map<string, Intl.DateTimeFormat>();\n\nfunction getTimeZoneParts(ms: number, timeZone: string) {\n let formatter = formattersByTimeZone.get(timeZone);\n if (!formatter) {\n formatter = new Intl.DateTimeFormat('en-US', {\n timeZone,\n hour12: false,\n era: 'short',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric'\n });\n\n formattersByTimeZone.set(timeZone, formatter);\n }\n\n let parts = formatter.formatToParts(new Date(ms));\n let namedParts: {[name: string]: string} = {};\n for (let part of parts) {\n if (part.type !== 'literal') {\n namedParts[part.type] = part.value;\n }\n }\n\n\n return {\n // Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253\n year: namedParts.era === 'BC' || namedParts.era === 'B' ? -namedParts.year + 1 : +namedParts.year,\n month: +namedParts.month,\n day: +namedParts.day,\n hour: namedParts.hour === '24' ? 0 : +namedParts.hour, // bugs.chromium.org/p/chromium/issues/detail?id=1045791\n minute: +namedParts.minute,\n second: +namedParts.second\n };\n}\n\nconst DAYMILLIS = 86400000;\n\nexport function possibleAbsolutes(date: CalendarDateTime, timeZone: string): number[] {\n let ms = epochFromDate(date);\n let earlier = ms - getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let later = ms - getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n return getValidWallTimes(date, timeZone, earlier, later);\n}\n\nfunction getValidWallTimes(date: CalendarDateTime, timeZone: string, earlier: number, later: number): number[] {\n let found = earlier === later ? [earlier] : [earlier, later];\n return found.filter(absolute => isValidWallTime(date, timeZone, absolute));\n}\n\nfunction isValidWallTime(date: CalendarDateTime, timeZone: string, absolute: number) {\n let parts = getTimeZoneParts(absolute, timeZone);\n return date.year === parts.year\n && date.month === parts.month\n && date.day === parts.day\n && date.hour === parts.hour\n && date.minute === parts.minute\n && date.second === parts.second;\n}\n\nexport function toAbsolute(date: CalendarDate | CalendarDateTime, timeZone: string, disambiguation: Disambiguation = 'compatible'): number {\n let dateTime = toCalendarDateTime(date);\n\n // Fast path: if the time zone is UTC, use native Date.\n if (timeZone === 'UTC') {\n return epochFromDate(dateTime);\n }\n\n // Fast path: if the time zone is the local timezone and disambiguation is compatible, use native Date.\n if (timeZone === getLocalTimeZone() && disambiguation === 'compatible') {\n dateTime = toCalendar(dateTime, new GregorianCalendar());\n\n // Don't use Date constructor here because two-digit years are interpreted in the 20th century.\n let date = new Date();\n let year = getExtendedYear(dateTime.era, dateTime.year);\n date.setFullYear(year, dateTime.month - 1, dateTime.day);\n date.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n return date.getTime();\n }\n\n let ms = epochFromDate(dateTime);\n let offsetBefore = getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let offsetAfter = getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n let valid = getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter);\n\n if (valid.length === 1) {\n return valid[0];\n }\n\n if (valid.length > 1) {\n switch (disambiguation) {\n // 'compatible' means 'earlier' for \"fall back\" transitions\n case 'compatible':\n case 'earlier':\n return valid[0];\n case 'later':\n return valid[valid.length - 1];\n case 'reject':\n throw new RangeError('Multiple possible absolute times found');\n }\n }\n\n switch (disambiguation) {\n case 'earlier':\n return Math.min(ms - offsetBefore, ms - offsetAfter);\n // 'compatible' means 'later' for \"spring forward\" transitions\n case 'compatible':\n case 'later':\n return Math.max(ms - offsetBefore, ms - offsetAfter);\n case 'reject':\n throw new RangeError('No such absolute time found');\n }\n}\n\nexport function toDate(dateTime: CalendarDate | CalendarDateTime, timeZone: string, disambiguation: Disambiguation = 'compatible'): Date {\n return new Date(toAbsolute(dateTime, timeZone, disambiguation));\n}\n\n/**\n * Takes a Unix epoch (milliseconds since 1970) and converts it to the provided time zone.\n */\nexport function fromAbsolute(ms: number, timeZone: string): ZonedDateTime {\n let offset = getTimeZoneOffset(ms, timeZone);\n let date = new Date(ms + offset);\n let year = date.getUTCFullYear();\n let month = date.getUTCMonth() + 1;\n let day = date.getUTCDate();\n let hour = date.getUTCHours();\n let minute = date.getUTCMinutes();\n let second = date.getUTCSeconds();\n let millisecond = date.getUTCMilliseconds();\n\n return new ZonedDateTime(year < 1 ? 'BC' : 'AD', year < 1 ? -year + 1 : year, month, day, timeZone, offset, hour, minute, second, millisecond);\n}\n\n/**\n * Takes a `Date` object and converts it to the provided time zone.\n */\nexport function fromDate(date: Date, timeZone: string): ZonedDateTime {\n return fromAbsolute(date.getTime(), timeZone);\n}\n\nexport function fromDateToLocal(date: Date): ZonedDateTime {\n return fromDate(date, getLocalTimeZone());\n}\n\n/** Converts a value with date components such as a `CalendarDateTime` or `ZonedDateTime` into a `CalendarDate`. */\nexport function toCalendarDate(dateTime: AnyCalendarDate): CalendarDate {\n return new CalendarDate(dateTime.calendar, dateTime.era, dateTime.year, dateTime.month, dateTime.day);\n}\n\nexport function toDateFields(date: AnyCalendarDate): DateFields {\n return {\n era: date.era,\n year: date.year,\n month: date.month,\n day: date.day\n };\n}\n\nexport function toTimeFields(date: AnyTime): TimeFields {\n return {\n hour: date.hour,\n minute: date.minute,\n second: date.second,\n millisecond: date.millisecond\n };\n}\n\n/**\n * Converts a date value to a `CalendarDateTime`. An optional `Time` value can be passed to set the time\n * of the resulting value, otherwise it will default to midnight.\n */\nexport function toCalendarDateTime(date: CalendarDate | CalendarDateTime | ZonedDateTime, time?: AnyTime): CalendarDateTime {\n let hour = 0, minute = 0, second = 0, millisecond = 0;\n if ('timeZone' in date) {\n ({hour, minute, second, millisecond} = date);\n } else if ('hour' in date && !time) {\n return date;\n }\n\n if (time) {\n ({hour, minute, second, millisecond} = time);\n }\n\n return new CalendarDateTime(\n date.calendar,\n date.era,\n date.year,\n date.month,\n date.day,\n hour,\n minute,\n second,\n millisecond\n );\n}\n\n/** Extracts the time components from a value containing a date and time. */\nexport function toTime(dateTime: CalendarDateTime | ZonedDateTime): Time {\n return new Time(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n}\n\n/** Converts a date from one calendar system to another. */\nexport function toCalendar<T extends AnyCalendarDate>(date: T, calendar: Calendar): T {\n if (isEqualCalendar(date.calendar, calendar)) {\n return date;\n }\n\n let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));\n let copy: Mutable<T> = date.copy();\n copy.calendar = calendar;\n copy.era = calendarDate.era;\n copy.year = calendarDate.year;\n copy.month = calendarDate.month;\n copy.day = calendarDate.day;\n constrain(copy);\n return copy;\n}\n\n/**\n * Converts a date value to a `ZonedDateTime` in the provided time zone. The `disambiguation` option can be set\n * to control how values that fall on daylight saving time changes are interpreted.\n */\nexport function toZoned(date: CalendarDate | CalendarDateTime | ZonedDateTime, timeZone: string, disambiguation?: Disambiguation): ZonedDateTime {\n if (date instanceof ZonedDateTime) {\n if (date.timeZone === timeZone) {\n return date;\n }\n\n return toTimeZone(date, timeZone);\n }\n\n let ms = toAbsolute(date, timeZone, disambiguation);\n return fromAbsolute(ms, timeZone);\n}\n\nexport function zonedToDate(date: ZonedDateTime): Date {\n let ms = epochFromDate(date) - date.offset;\n return new Date(ms);\n}\n\n/** Converts a `ZonedDateTime` from one time zone to another. */\nexport function toTimeZone(date: ZonedDateTime, timeZone: string): ZonedDateTime {\n let ms = epochFromDate(date) - date.offset;\n return toCalendar(fromAbsolute(ms, timeZone), date.calendar);\n}\n\n/** Converts the given `ZonedDateTime` into the user's local time zone. */\nexport function toLocalTimeZone(date: ZonedDateTime): ZonedDateTime {\n return toTimeZone(date, getLocalTimeZone());\n}\n"],"names":[],"version":3,"file":"conversion.main.js.map"}
@@ -1,7 +1,7 @@
1
1
  import {CalendarDate as $35ea8db9cb2ccb90$export$99faa760c7908e4f, CalendarDateTime as $35ea8db9cb2ccb90$export$ca871e8dbb80966f, Time as $35ea8db9cb2ccb90$export$680ea196effce5f, ZonedDateTime as $35ea8db9cb2ccb90$export$d3b7288e7994edea} from "./CalendarDate.mjs";
2
2
  import {constrain as $735220c2d4774dd3$export$c4e2ecac49351ef2} from "./manipulation.mjs";
3
3
  import {getExtendedYear as $3b62074eb05584b2$export$c36e0ecb2d4fa69d, GregorianCalendar as $3b62074eb05584b2$export$80ee6245ec4f29ec} from "./GregorianCalendar.mjs";
4
- import {getLocalTimeZone as $14e0f24ef4ac5c92$export$aa8b41735afcabd2} from "./queries.mjs";
4
+ import {getLocalTimeZone as $14e0f24ef4ac5c92$export$aa8b41735afcabd2, isEqualCalendar as $14e0f24ef4ac5c92$export$dbc69fd56b53d5e} from "./queries.mjs";
5
5
 
6
6
  /*
7
7
  * Copyright 2020 Adobe. All rights reserved.
@@ -182,7 +182,7 @@ function $11d87f3f76e88657$export$d33f79e3ffc3dc83(dateTime) {
182
182
  return new (0, $35ea8db9cb2ccb90$export$680ea196effce5f)(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);
183
183
  }
184
184
  function $11d87f3f76e88657$export$b4a036af3fc0b032(date, calendar) {
185
- if (date.calendar.identifier === calendar.identifier) return date;
185
+ if ((0, $14e0f24ef4ac5c92$export$dbc69fd56b53d5e)(date.calendar, calendar)) return date;
186
186
  let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));
187
187
  let copy = date.copy();
188
188
  copy.calendar = calendar;
@@ -1,7 +1,7 @@
1
1
  import {CalendarDate as $35ea8db9cb2ccb90$export$99faa760c7908e4f, CalendarDateTime as $35ea8db9cb2ccb90$export$ca871e8dbb80966f, Time as $35ea8db9cb2ccb90$export$680ea196effce5f, ZonedDateTime as $35ea8db9cb2ccb90$export$d3b7288e7994edea} from "./CalendarDate.module.js";
2
2
  import {constrain as $735220c2d4774dd3$export$c4e2ecac49351ef2} from "./manipulation.module.js";
3
3
  import {getExtendedYear as $3b62074eb05584b2$export$c36e0ecb2d4fa69d, GregorianCalendar as $3b62074eb05584b2$export$80ee6245ec4f29ec} from "./GregorianCalendar.module.js";
4
- import {getLocalTimeZone as $14e0f24ef4ac5c92$export$aa8b41735afcabd2} from "./queries.module.js";
4
+ import {getLocalTimeZone as $14e0f24ef4ac5c92$export$aa8b41735afcabd2, isEqualCalendar as $14e0f24ef4ac5c92$export$dbc69fd56b53d5e} from "./queries.module.js";
5
5
 
6
6
  /*
7
7
  * Copyright 2020 Adobe. All rights reserved.
@@ -182,7 +182,7 @@ function $11d87f3f76e88657$export$d33f79e3ffc3dc83(dateTime) {
182
182
  return new (0, $35ea8db9cb2ccb90$export$680ea196effce5f)(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);
183
183
  }
184
184
  function $11d87f3f76e88657$export$b4a036af3fc0b032(date, calendar) {
185
- if (date.calendar.identifier === calendar.identifier) return date;
185
+ if ((0, $14e0f24ef4ac5c92$export$dbc69fd56b53d5e)(date.calendar, calendar)) return date;
186
186
  let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));
187
187
  let copy = date.copy();
188
188
  copy.calendar = calendar;
@@ -1 +1 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BAAgB,CAAA,GAAA,yCAAY,GAAG;QACjC,IAAI,KAAK,QAAQ,KAAK,UACpB,OAAO;QAGT,OAAO,0CAAW,MAAM;IAC1B;IAEA,IAAI,KAAK,0CAAW,MAAM,UAAU;IACpC,OAAO,0CAAa,IAAI;AAC1B;AAEO,SAAS,yCAAY,IAAmB;IAC7C,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,IAAI,KAAK;AAClB;AAGO,SAAS,0CAAW,IAAmB,EAAE,QAAgB;IAC9D,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,0CAAW,0CAAa,IAAI,WAAW,KAAK,QAAQ;AAC7D;AAGO,SAAS,0CAAgB,IAAmB;IACjD,OAAO,0CAAW,MAAM,CAAA,GAAA,yCAAe;AACzC","sources":["packages/@internationalized/date/src/conversion.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, AnyDateTime, AnyTime, Calendar, DateFields, Disambiguation, TimeFields} from './types';\nimport {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from './CalendarDate';\nimport {constrain} from './manipulation';\nimport {getExtendedYear, GregorianCalendar} from './calendars/GregorianCalendar';\nimport {getLocalTimeZone} from './queries';\nimport {Mutable} from './utils';\n\nexport function epochFromDate(date: AnyDateTime) {\n date = toCalendar(date, new GregorianCalendar());\n let year = getExtendedYear(date.era, date.year);\n return epochFromParts(year, date.month, date.day, date.hour, date.minute, date.second, date.millisecond);\n}\n\nfunction epochFromParts(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number) {\n // Note: Date.UTC() interprets one and two-digit years as being in the\n // 20th century, so don't use it\n let date = new Date();\n date.setUTCHours(hour, minute, second, millisecond);\n date.setUTCFullYear(year, month - 1, day);\n return date.getTime();\n}\n\nexport function getTimeZoneOffset(ms: number, timeZone: string) {\n // Fast path for UTC.\n if (timeZone === 'UTC') {\n return 0;\n }\n\n // Fast path: for local timezone after 1970, use native Date.\n if (ms > 0 && timeZone === getLocalTimeZone()) {\n return new Date(ms).getTimezoneOffset() * -60 * 1000;\n }\n\n let {year, month, day, hour, minute, second} = getTimeZoneParts(ms, timeZone);\n let utc = epochFromParts(year, month, day, hour, minute, second, 0);\n return utc - Math.floor(ms / 1000) * 1000;\n}\n\nconst formattersByTimeZone = new Map<string, Intl.DateTimeFormat>();\n\nfunction getTimeZoneParts(ms: number, timeZone: string) {\n let formatter = formattersByTimeZone.get(timeZone);\n if (!formatter) {\n formatter = new Intl.DateTimeFormat('en-US', {\n timeZone,\n hour12: false,\n era: 'short',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric'\n });\n\n formattersByTimeZone.set(timeZone, formatter);\n }\n\n let parts = formatter.formatToParts(new Date(ms));\n let namedParts: {[name: string]: string} = {};\n for (let part of parts) {\n if (part.type !== 'literal') {\n namedParts[part.type] = part.value;\n }\n }\n\n\n return {\n // Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253\n year: namedParts.era === 'BC' || namedParts.era === 'B' ? -namedParts.year + 1 : +namedParts.year,\n month: +namedParts.month,\n day: +namedParts.day,\n hour: namedParts.hour === '24' ? 0 : +namedParts.hour, // bugs.chromium.org/p/chromium/issues/detail?id=1045791\n minute: +namedParts.minute,\n second: +namedParts.second\n };\n}\n\nconst DAYMILLIS = 86400000;\n\nexport function possibleAbsolutes(date: CalendarDateTime, timeZone: string): number[] {\n let ms = epochFromDate(date);\n let earlier = ms - getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let later = ms - getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n return getValidWallTimes(date, timeZone, earlier, later);\n}\n\nfunction getValidWallTimes(date: CalendarDateTime, timeZone: string, earlier: number, later: number): number[] {\n let found = earlier === later ? [earlier] : [earlier, later];\n return found.filter(absolute => isValidWallTime(date, timeZone, absolute));\n}\n\nfunction isValidWallTime(date: CalendarDateTime, timeZone: string, absolute: number) {\n let parts = getTimeZoneParts(absolute, timeZone);\n return date.year === parts.year\n && date.month === parts.month\n && date.day === parts.day\n && date.hour === parts.hour\n && date.minute === parts.minute\n && date.second === parts.second;\n}\n\nexport function toAbsolute(date: CalendarDate | CalendarDateTime, timeZone: string, disambiguation: Disambiguation = 'compatible'): number {\n let dateTime = toCalendarDateTime(date);\n\n // Fast path: if the time zone is UTC, use native Date.\n if (timeZone === 'UTC') {\n return epochFromDate(dateTime);\n }\n\n // Fast path: if the time zone is the local timezone and disambiguation is compatible, use native Date.\n if (timeZone === getLocalTimeZone() && disambiguation === 'compatible') {\n dateTime = toCalendar(dateTime, new GregorianCalendar());\n\n // Don't use Date constructor here because two-digit years are interpreted in the 20th century.\n let date = new Date();\n let year = getExtendedYear(dateTime.era, dateTime.year);\n date.setFullYear(year, dateTime.month - 1, dateTime.day);\n date.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n return date.getTime();\n }\n\n let ms = epochFromDate(dateTime);\n let offsetBefore = getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let offsetAfter = getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n let valid = getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter);\n\n if (valid.length === 1) {\n return valid[0];\n }\n\n if (valid.length > 1) {\n switch (disambiguation) {\n // 'compatible' means 'earlier' for \"fall back\" transitions\n case 'compatible':\n case 'earlier':\n return valid[0];\n case 'later':\n return valid[valid.length - 1];\n case 'reject':\n throw new RangeError('Multiple possible absolute times found');\n }\n }\n\n switch (disambiguation) {\n case 'earlier':\n return Math.min(ms - offsetBefore, ms - offsetAfter);\n // 'compatible' means 'later' for \"spring forward\" transitions\n case 'compatible':\n case 'later':\n return Math.max(ms - offsetBefore, ms - offsetAfter);\n case 'reject':\n throw new RangeError('No such absolute time found');\n }\n}\n\nexport function toDate(dateTime: CalendarDate | CalendarDateTime, timeZone: string, disambiguation: Disambiguation = 'compatible'): Date {\n return new Date(toAbsolute(dateTime, timeZone, disambiguation));\n}\n\n/**\n * Takes a Unix epoch (milliseconds since 1970) and converts it to the provided time zone.\n */\nexport function fromAbsolute(ms: number, timeZone: string): ZonedDateTime {\n let offset = getTimeZoneOffset(ms, timeZone);\n let date = new Date(ms + offset);\n let year = date.getUTCFullYear();\n let month = date.getUTCMonth() + 1;\n let day = date.getUTCDate();\n let hour = date.getUTCHours();\n let minute = date.getUTCMinutes();\n let second = date.getUTCSeconds();\n let millisecond = date.getUTCMilliseconds();\n\n return new ZonedDateTime(year < 1 ? 'BC' : 'AD', year < 1 ? -year + 1 : year, month, day, timeZone, offset, hour, minute, second, millisecond);\n}\n\n/**\n * Takes a `Date` object and converts it to the provided time zone.\n */\nexport function fromDate(date: Date, timeZone: string): ZonedDateTime {\n return fromAbsolute(date.getTime(), timeZone);\n}\n\nexport function fromDateToLocal(date: Date): ZonedDateTime {\n return fromDate(date, getLocalTimeZone());\n}\n\n/** Converts a value with date components such as a `CalendarDateTime` or `ZonedDateTime` into a `CalendarDate`. */\nexport function toCalendarDate(dateTime: AnyCalendarDate): CalendarDate {\n return new CalendarDate(dateTime.calendar, dateTime.era, dateTime.year, dateTime.month, dateTime.day);\n}\n\nexport function toDateFields(date: AnyCalendarDate): DateFields {\n return {\n era: date.era,\n year: date.year,\n month: date.month,\n day: date.day\n };\n}\n\nexport function toTimeFields(date: AnyTime): TimeFields {\n return {\n hour: date.hour,\n minute: date.minute,\n second: date.second,\n millisecond: date.millisecond\n };\n}\n\n/**\n * Converts a date value to a `CalendarDateTime`. An optional `Time` value can be passed to set the time\n * of the resulting value, otherwise it will default to midnight.\n */\nexport function toCalendarDateTime(date: CalendarDate | CalendarDateTime | ZonedDateTime, time?: AnyTime): CalendarDateTime {\n let hour = 0, minute = 0, second = 0, millisecond = 0;\n if ('timeZone' in date) {\n ({hour, minute, second, millisecond} = date);\n } else if ('hour' in date && !time) {\n return date;\n }\n\n if (time) {\n ({hour, minute, second, millisecond} = time);\n }\n\n return new CalendarDateTime(\n date.calendar,\n date.era,\n date.year,\n date.month,\n date.day,\n hour,\n minute,\n second,\n millisecond\n );\n}\n\n/** Extracts the time components from a value containing a date and time. */\nexport function toTime(dateTime: CalendarDateTime | ZonedDateTime): Time {\n return new Time(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n}\n\n/** Converts a date from one calendar system to another. */\nexport function toCalendar<T extends AnyCalendarDate>(date: T, calendar: Calendar): T {\n if (date.calendar.identifier === calendar.identifier) {\n return date;\n }\n\n let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));\n let copy: Mutable<T> = date.copy();\n copy.calendar = calendar;\n copy.era = calendarDate.era;\n copy.year = calendarDate.year;\n copy.month = calendarDate.month;\n copy.day = calendarDate.day;\n constrain(copy);\n return copy;\n}\n\n/**\n * Converts a date value to a `ZonedDateTime` in the provided time zone. The `disambiguation` option can be set\n * to control how values that fall on daylight saving time changes are interpreted.\n */\nexport function toZoned(date: CalendarDate | CalendarDateTime | ZonedDateTime, timeZone: string, disambiguation?: Disambiguation): ZonedDateTime {\n if (date instanceof ZonedDateTime) {\n if (date.timeZone === timeZone) {\n return date;\n }\n\n return toTimeZone(date, timeZone);\n }\n\n let ms = toAbsolute(date, timeZone, disambiguation);\n return fromAbsolute(ms, timeZone);\n}\n\nexport function zonedToDate(date: ZonedDateTime) {\n let ms = epochFromDate(date) - date.offset;\n return new Date(ms);\n}\n\n/** Converts a `ZonedDateTime` from one time zone to another. */\nexport function toTimeZone(date: ZonedDateTime, timeZone: string): ZonedDateTime {\n let ms = epochFromDate(date) - date.offset;\n return toCalendar(fromAbsolute(ms, timeZone), date.calendar);\n}\n\n/** Converts the given `ZonedDateTime` into the user's local time zone. */\nexport function toLocalTimeZone(date: ZonedDateTime): ZonedDateTime {\n return toTimeZone(date, getLocalTimeZone());\n}\n"],"names":[],"version":3,"file":"conversion.module.js.map"}
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;;;AASzF,SAAS,yCAAc,IAAiB;IAC7C,OAAO,0CAAW,MAAM,IAAI,CAAA,GAAA,yCAAgB;IAC5C,IAAI,OAAO,CAAA,GAAA,yCAAc,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI;IAC9C,OAAO,qCAAe,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW;AACzG;AAEA,SAAS,qCAAe,IAAY,EAAE,KAAa,EAAE,GAAW,EAAE,IAAY,EAAE,MAAc,EAAE,MAAc,EAAE,WAAmB;IACjI,sEAAsE;IACtE,gCAAgC;IAChC,IAAI,OAAO,IAAI;IACf,KAAK,WAAW,CAAC,MAAM,QAAQ,QAAQ;IACvC,KAAK,cAAc,CAAC,MAAM,QAAQ,GAAG;IACrC,OAAO,KAAK,OAAO;AACrB;AAEO,SAAS,0CAAkB,EAAU,EAAE,QAAgB;IAC5D,qBAAqB;IACrB,IAAI,aAAa,OACf,OAAO;IAGT,6DAA6D;IAC7D,IAAI,KAAK,KAAK,aAAa,CAAA,GAAA,yCAAe,KACxC,OAAO,IAAI,KAAK,IAAI,iBAAiB,KAA9B;IAGT,IAAI,QAAC,IAAI,SAAE,KAAK,OAAE,GAAG,QAAE,IAAI,UAAE,MAAM,UAAE,MAAM,EAAC,GAAG,uCAAiB,IAAI;IACpE,IAAI,MAAM,qCAAe,MAAM,OAA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KAAK,GAAG,GAAG,aAAa,GAAG;IAC3B,KAAK,IAAI,GAAG,aAAa,IAAI;IAC7B,KAAK,KAAK,GAAG,aAAa,KAAK;IAC/B,KAAK,GAAG,GAAG,aAAa,GAAG;IAC3B,CAAA,GAAA,yCAAQ,EAAE;IACV,OAAO;AACT;AAMO,SAAS,0CAAQ,IAAqD,EAAE,QAAgB,EAAE,cAA+B;IAC9H,IAAI,gBAAgB,CAAA,GAAA,yCAAY,GAAG;QACjC,IAAI,KAAK,QAAQ,KAAK,UACpB,OAAO;QAGT,OAAO,0CAAW,MAAM;IAC1B;IAEA,IAAI,KAAK,0CAAW,MAAM,UAAU;IACpC,OAAO,0CAAa,IAAI;AAC1B;AAEO,SAAS,yCAAY,IAAmB;IAC7C,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,IAAI,KAAK;AAClB;AAGO,SAAS,0CAAW,IAAmB,EAAE,QAAgB;IAC9D,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,0CAAW,0CAAa,IAAI,WAAW,KAAK,QAAQ;AAC7D;AAGO,SAAS,0CAAgB,IAAmB;IACjD,OAAO,0CAAW,MAAM,CAAA,GAAA,yCAAe;AACzC","sources":["packages/@internationalized/date/src/conversion.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, AnyDateTime, AnyTime, Calendar, DateFields, Disambiguation, TimeFields} from './types';\nimport {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from './CalendarDate';\nimport {constrain} from './manipulation';\nimport {getExtendedYear, GregorianCalendar} from './calendars/GregorianCalendar';\nimport {getLocalTimeZone, isEqualCalendar} from './queries';\nimport {Mutable} from './utils';\n\nexport function epochFromDate(date: AnyDateTime): number {\n date = toCalendar(date, new GregorianCalendar());\n let year = getExtendedYear(date.era, date.year);\n return epochFromParts(year, date.month, date.day, date.hour, date.minute, date.second, date.millisecond);\n}\n\nfunction epochFromParts(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number): number {\n // Note: Date.UTC() interprets one and two-digit years as being in the\n // 20th century, so don't use it\n let date = new Date();\n date.setUTCHours(hour, minute, second, millisecond);\n date.setUTCFullYear(year, month - 1, day);\n return date.getTime();\n}\n\nexport function getTimeZoneOffset(ms: number, timeZone: string): number {\n // Fast path for UTC.\n if (timeZone === 'UTC') {\n return 0;\n }\n\n // Fast path: for local timezone after 1970, use native Date.\n if (ms > 0 && timeZone === getLocalTimeZone()) {\n return new Date(ms).getTimezoneOffset() * -60 * 1000;\n }\n\n let {year, month, day, hour, minute, second} = getTimeZoneParts(ms, timeZone);\n let utc = epochFromParts(year, month, day, hour, minute, second, 0);\n return utc - Math.floor(ms / 1000) * 1000;\n}\n\nconst formattersByTimeZone = new Map<string, Intl.DateTimeFormat>();\n\nfunction getTimeZoneParts(ms: number, timeZone: string) {\n let formatter = formattersByTimeZone.get(timeZone);\n if (!formatter) {\n formatter = new Intl.DateTimeFormat('en-US', {\n timeZone,\n hour12: false,\n era: 'short',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric'\n });\n\n formattersByTimeZone.set(timeZone, formatter);\n }\n\n let parts = formatter.formatToParts(new Date(ms));\n let namedParts: {[name: string]: string} = {};\n for (let part of parts) {\n if (part.type !== 'literal') {\n namedParts[part.type] = part.value;\n }\n }\n\n\n return {\n // Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253\n year: namedParts.era === 'BC' || namedParts.era === 'B' ? -namedParts.year + 1 : +namedParts.year,\n month: +namedParts.month,\n day: +namedParts.day,\n hour: namedParts.hour === '24' ? 0 : +namedParts.hour, // bugs.chromium.org/p/chromium/issues/detail?id=1045791\n minute: +namedParts.minute,\n second: +namedParts.second\n };\n}\n\nconst DAYMILLIS = 86400000;\n\nexport function possibleAbsolutes(date: CalendarDateTime, timeZone: string): number[] {\n let ms = epochFromDate(date);\n let earlier = ms - getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let later = ms - getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n return getValidWallTimes(date, timeZone, earlier, later);\n}\n\nfunction getValidWallTimes(date: CalendarDateTime, timeZone: string, earlier: number, later: number): number[] {\n let found = earlier === later ? [earlier] : [earlier, later];\n return found.filter(absolute => isValidWallTime(date, timeZone, absolute));\n}\n\nfunction isValidWallTime(date: CalendarDateTime, timeZone: string, absolute: number) {\n let parts = getTimeZoneParts(absolute, timeZone);\n return date.year === parts.year\n && date.month === parts.month\n && date.day === parts.day\n && date.hour === parts.hour\n && date.minute === parts.minute\n && date.second === parts.second;\n}\n\nexport function toAbsolute(date: CalendarDate | CalendarDateTime, timeZone: string, disambiguation: Disambiguation = 'compatible'): number {\n let dateTime = toCalendarDateTime(date);\n\n // Fast path: if the time zone is UTC, use native Date.\n if (timeZone === 'UTC') {\n return epochFromDate(dateTime);\n }\n\n // Fast path: if the time zone is the local timezone and disambiguation is compatible, use native Date.\n if (timeZone === getLocalTimeZone() && disambiguation === 'compatible') {\n dateTime = toCalendar(dateTime, new GregorianCalendar());\n\n // Don't use Date constructor here because two-digit years are interpreted in the 20th century.\n let date = new Date();\n let year = getExtendedYear(dateTime.era, dateTime.year);\n date.setFullYear(year, dateTime.month - 1, dateTime.day);\n date.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n return date.getTime();\n }\n\n let ms = epochFromDate(dateTime);\n let offsetBefore = getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let offsetAfter = getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n let valid = getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter);\n\n if (valid.length === 1) {\n return valid[0];\n }\n\n if (valid.length > 1) {\n switch (disambiguation) {\n // 'compatible' means 'earlier' for \"fall back\" transitions\n case 'compatible':\n case 'earlier':\n return valid[0];\n case 'later':\n return valid[valid.length - 1];\n case 'reject':\n throw new RangeError('Multiple possible absolute times found');\n }\n }\n\n switch (disambiguation) {\n case 'earlier':\n return Math.min(ms - offsetBefore, ms - offsetAfter);\n // 'compatible' means 'later' for \"spring forward\" transitions\n case 'compatible':\n case 'later':\n return Math.max(ms - offsetBefore, ms - offsetAfter);\n case 'reject':\n throw new RangeError('No such absolute time found');\n }\n}\n\nexport function toDate(dateTime: CalendarDate | CalendarDateTime, timeZone: string, disambiguation: Disambiguation = 'compatible'): Date {\n return new Date(toAbsolute(dateTime, timeZone, disambiguation));\n}\n\n/**\n * Takes a Unix epoch (milliseconds since 1970) and converts it to the provided time zone.\n */\nexport function fromAbsolute(ms: number, timeZone: string): ZonedDateTime {\n let offset = getTimeZoneOffset(ms, timeZone);\n let date = new Date(ms + offset);\n let year = date.getUTCFullYear();\n let month = date.getUTCMonth() + 1;\n let day = date.getUTCDate();\n let hour = date.getUTCHours();\n let minute = date.getUTCMinutes();\n let second = date.getUTCSeconds();\n let millisecond = date.getUTCMilliseconds();\n\n return new ZonedDateTime(year < 1 ? 'BC' : 'AD', year < 1 ? -year + 1 : year, month, day, timeZone, offset, hour, minute, second, millisecond);\n}\n\n/**\n * Takes a `Date` object and converts it to the provided time zone.\n */\nexport function fromDate(date: Date, timeZone: string): ZonedDateTime {\n return fromAbsolute(date.getTime(), timeZone);\n}\n\nexport function fromDateToLocal(date: Date): ZonedDateTime {\n return fromDate(date, getLocalTimeZone());\n}\n\n/** Converts a value with date components such as a `CalendarDateTime` or `ZonedDateTime` into a `CalendarDate`. */\nexport function toCalendarDate(dateTime: AnyCalendarDate): CalendarDate {\n return new CalendarDate(dateTime.calendar, dateTime.era, dateTime.year, dateTime.month, dateTime.day);\n}\n\nexport function toDateFields(date: AnyCalendarDate): DateFields {\n return {\n era: date.era,\n year: date.year,\n month: date.month,\n day: date.day\n };\n}\n\nexport function toTimeFields(date: AnyTime): TimeFields {\n return {\n hour: date.hour,\n minute: date.minute,\n second: date.second,\n millisecond: date.millisecond\n };\n}\n\n/**\n * Converts a date value to a `CalendarDateTime`. An optional `Time` value can be passed to set the time\n * of the resulting value, otherwise it will default to midnight.\n */\nexport function toCalendarDateTime(date: CalendarDate | CalendarDateTime | ZonedDateTime, time?: AnyTime): CalendarDateTime {\n let hour = 0, minute = 0, second = 0, millisecond = 0;\n if ('timeZone' in date) {\n ({hour, minute, second, millisecond} = date);\n } else if ('hour' in date && !time) {\n return date;\n }\n\n if (time) {\n ({hour, minute, second, millisecond} = time);\n }\n\n return new CalendarDateTime(\n date.calendar,\n date.era,\n date.year,\n date.month,\n date.day,\n hour,\n minute,\n second,\n millisecond\n );\n}\n\n/** Extracts the time components from a value containing a date and time. */\nexport function toTime(dateTime: CalendarDateTime | ZonedDateTime): Time {\n return new Time(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n}\n\n/** Converts a date from one calendar system to another. */\nexport function toCalendar<T extends AnyCalendarDate>(date: T, calendar: Calendar): T {\n if (isEqualCalendar(date.calendar, calendar)) {\n return date;\n }\n\n let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));\n let copy: Mutable<T> = date.copy();\n copy.calendar = calendar;\n copy.era = calendarDate.era;\n copy.year = calendarDate.year;\n copy.month = calendarDate.month;\n copy.day = calendarDate.day;\n constrain(copy);\n return copy;\n}\n\n/**\n * Converts a date value to a `ZonedDateTime` in the provided time zone. The `disambiguation` option can be set\n * to control how values that fall on daylight saving time changes are interpreted.\n */\nexport function toZoned(date: CalendarDate | CalendarDateTime | ZonedDateTime, timeZone: string, disambiguation?: Disambiguation): ZonedDateTime {\n if (date instanceof ZonedDateTime) {\n if (date.timeZone === timeZone) {\n return date;\n }\n\n return toTimeZone(date, timeZone);\n }\n\n let ms = toAbsolute(date, timeZone, disambiguation);\n return fromAbsolute(ms, timeZone);\n}\n\nexport function zonedToDate(date: ZonedDateTime): Date {\n let ms = epochFromDate(date) - date.offset;\n return new Date(ms);\n}\n\n/** Converts a `ZonedDateTime` from one time zone to another. */\nexport function toTimeZone(date: ZonedDateTime, timeZone: string): ZonedDateTime {\n let ms = epochFromDate(date) - date.offset;\n return toCalendar(fromAbsolute(ms, timeZone), date.calendar);\n}\n\n/** Converts the given `ZonedDateTime` into the user's local time zone. */\nexport function toLocalTimeZone(date: ZonedDateTime): ZonedDateTime {\n return toTimeZone(date, getLocalTimeZone());\n}\n"],"names":[],"version":3,"file":"conversion.module.js.map"}