ilib-webos 14.19.0-webos2 → 14.20.0-webos1
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.
- package/lib/Address.js +1 -1
- package/lib/AddressFmt.js +1 -1
- package/lib/AlphabeticIndex.js +1 -1
- package/lib/Astro.js +1 -1
- package/lib/AsyncNodeLoader.js +1 -1
- package/lib/CType.js +1 -1
- package/lib/CalendarFactory.js +2 -2
- package/lib/CaseMapper.js +1 -1
- package/lib/Charmap.js +1 -1
- package/lib/CharmapFactory.js +2 -2
- package/lib/CharmapTable.js +1 -1
- package/lib/Charset.js +1 -1
- package/lib/CodePointSource.js +1 -1
- package/lib/Collator.js +1 -1
- package/lib/Country.js +1 -1
- package/lib/DateFactory.js +2 -2
- package/lib/DateFmt.js +1 -1
- package/lib/DateRngFmt.js +1 -1
- package/lib/DigitalSpeedUnit.js +1 -1
- package/lib/DigitalStorageUnit.js +1 -1
- package/lib/DurationFmt.js +1 -1
- package/lib/EthiopicDate.js +1 -1
- package/lib/EthiopicRataDie.js +1 -1
- package/lib/ForceUnit.js +1 -1
- package/lib/GlyphString.js +1 -1
- package/lib/GregRataDie.js +1 -1
- package/lib/GregorianCal.js +1 -1
- package/lib/GregorianDate.js +1 -1
- package/lib/HanCal.js +1 -1
- package/lib/HanDate.js +1 -1
- package/lib/HanRataDie.js +1 -1
- package/lib/HebrewCal.js +1 -1
- package/lib/HebrewDate.js +1 -1
- package/lib/HebrewRataDie.js +1 -1
- package/lib/IDate.js +1 -1
- package/lib/INumber.js +1 -1
- package/lib/IString.js +1 -1
- package/lib/IslamicDate.js +1 -1
- package/lib/IslamicRataDie.js +1 -1
- package/lib/JSUtils.js +1 -1
- package/lib/JulianDate.js +1 -1
- package/lib/JulianRataDie.js +1 -1
- package/lib/ListFmt.js +1 -1
- package/lib/Loader.js +1 -1
- package/lib/Locale.js +2 -2
- package/lib/LocaleInfo.js +1 -1
- package/lib/LocaleMatcher.js +1 -1
- package/lib/MathUtils.js +1 -1
- package/lib/Measurement.js +1 -1
- package/lib/MeasurementFactory.js +1 -1
- package/lib/Name.js +1 -1
- package/lib/NameFmt.js +1 -1
- package/lib/NodeLoader.js +1 -1
- package/lib/NormString.js +1 -1
- package/lib/NumFmt.js +1 -1
- package/lib/NumberingPlan.js +1 -1
- package/lib/Path.js +1 -1
- package/lib/PersAlgoRataDie.js +1 -1
- package/lib/PersRataDie.js +1 -1
- package/lib/PersianAlgoCal.js +1 -1
- package/lib/PersianAlgoDate.js +1 -1
- package/lib/PersianCal.js +1 -1
- package/lib/PersianDate.js +1 -1
- package/lib/PhoneFmt.js +1 -1
- package/lib/PhoneGeoLocator.js +1 -1
- package/lib/PhoneHandlerFactory.js +1 -1
- package/lib/PhoneLocale.js +1 -1
- package/lib/PhoneNumber.js +1 -1
- package/lib/PowerUnit.js +1 -1
- package/lib/PressureUnit.js +1 -1
- package/lib/QMLLoader.js +1 -1
- package/lib/RataDie.js +1 -1
- package/lib/ResBundle.js +1 -1
- package/lib/ScriptInfo.js +1 -1
- package/lib/SearchUtils.js +1 -1
- package/lib/StringMapper.js +1 -1
- package/lib/ThaiSolarCal.js +1 -1
- package/lib/ThaiSolarDate.js +1 -1
- package/lib/TimeZone.js +1 -1
- package/lib/UTF16LE.js +1 -1
- package/lib/UTF8.js +1 -1
- package/lib/UnitFmt.js +1 -1
- package/lib/Utils.js +1 -1
- package/lib/WebLoader.js +1 -1
- package/lib/WebpackLoader.js +1 -3
- package/lib/ilib-qt.js +1 -1
- package/lib/ilib-web.js +1 -1
- package/lib/ilib.js +1 -1
- package/locale/af/unitfmt.json +1 -1
- package/locale/am/ctrynames.json +1 -1
- package/locale/am/ctryreverse.json +1 -1
- package/locale/am/list.json +1 -1
- package/locale/am/sysres.json +1 -1
- package/locale/am/unitfmt.json +1 -1
- package/locale/ar/AE/ctrynames.json +1 -1
- package/locale/ar/AE/ctryreverse.json +1 -1
- package/locale/ar/AE/localeinfo.json +1 -1
- package/locale/ar/BH/ctrynames.json +1 -1
- package/locale/ar/BH/ctryreverse.json +1 -1
- package/locale/ar/DJ/ctrynames.json +1 -1
- package/locale/ar/DJ/ctryreverse.json +1 -1
- package/locale/ar/DZ/ctrynames.json +1 -1
- package/locale/ar/DZ/ctryreverse.json +1 -1
- package/locale/ar/DZ/localeinfo.json +1 -1
- package/locale/ar/EG/ctrynames.json +1 -1
- package/locale/ar/EG/ctryreverse.json +1 -1
- package/locale/ar/EH/ctrynames.json +1 -1
- package/locale/ar/EH/ctryreverse.json +1 -1
- package/locale/ar/EH/localeinfo.json +1 -1
- package/locale/ar/ER/ctrynames.json +1 -1
- package/locale/ar/ER/ctryreverse.json +1 -1
- package/locale/ar/IL/ctrynames.json +1 -1
- package/locale/ar/IL/ctryreverse.json +1 -1
- package/locale/ar/IQ/ctrynames.json +1 -1
- package/locale/ar/IQ/ctryreverse.json +1 -1
- package/locale/ar/JO/ctrynames.json +1 -1
- package/locale/ar/JO/ctryreverse.json +1 -1
- package/locale/ar/KM/ctrynames.json +1 -1
- package/locale/ar/KM/ctryreverse.json +1 -1
- package/locale/ar/KW/ctrynames.json +1 -1
- package/locale/ar/KW/ctryreverse.json +1 -1
- package/locale/ar/LB/ctrynames.json +1 -1
- package/locale/ar/LB/ctryreverse.json +1 -1
- package/locale/ar/LY/ctrynames.json +1 -1
- package/locale/ar/LY/ctryreverse.json +1 -1
- package/locale/ar/LY/localeinfo.json +1 -1
- package/locale/ar/MA/ctrynames.json +1 -1
- package/locale/ar/MA/ctryreverse.json +1 -1
- package/locale/ar/MA/localeinfo.json +1 -1
- package/locale/ar/MR/ctrynames.json +1 -1
- package/locale/ar/MR/ctryreverse.json +1 -1
- package/locale/ar/OM/ctrynames.json +1 -1
- package/locale/ar/OM/ctryreverse.json +1 -1
- package/locale/ar/PS/ctrynames.json +1 -1
- package/locale/ar/PS/ctryreverse.json +1 -1
- package/locale/ar/QA/ctrynames.json +1 -1
- package/locale/ar/QA/ctryreverse.json +1 -1
- package/locale/ar/SA/ctrynames.json +1 -1
- package/locale/ar/SA/ctryreverse.json +1 -1
- package/locale/ar/SA/unitfmt.json +1 -1
- package/locale/ar/SD/ctrynames.json +1 -1
- package/locale/ar/SD/ctryreverse.json +1 -1
- package/locale/ar/SO/ctrynames.json +1 -1
- package/locale/ar/SO/ctryreverse.json +1 -1
- package/locale/ar/SS/ctrynames.json +1 -1
- package/locale/ar/SS/ctryreverse.json +1 -1
- package/locale/ar/SY/ctrynames.json +1 -1
- package/locale/ar/SY/ctryreverse.json +1 -1
- package/locale/ar/TD/ctrynames.json +1 -1
- package/locale/ar/TD/ctryreverse.json +1 -1
- package/locale/ar/TN/ctrynames.json +1 -1
- package/locale/ar/TN/ctryreverse.json +1 -1
- package/locale/ar/TN/localeinfo.json +1 -1
- package/locale/ar/YE/ctrynames.json +1 -1
- package/locale/ar/YE/ctryreverse.json +1 -1
- package/locale/ar/ctrynames.json +1 -1
- package/locale/ar/ctryreverse.json +1 -1
- package/locale/ar/localeinfo.json +1 -1
- package/locale/ar/unitfmt.json +1 -1
- package/locale/as/unitfmt.json +1 -1
- package/locale/az/Arab/IQ/unitfmt.json +1 -1
- package/locale/az/Arab/TR/unitfmt.json +1 -1
- package/locale/az/Arab/unitfmt.json +1 -1
- package/locale/az/Cyrl/ctrynames.json +1 -1
- package/locale/az/Cyrl/ctryreverse.json +1 -1
- package/locale/az/Cyrl/unitfmt.json +1 -1
- package/locale/az/unitfmt.json +1 -1
- package/locale/be/ctrynames.json +1 -1
- package/locale/be/ctryreverse.json +1 -1
- package/locale/be/sysres.json +1 -1
- package/locale/be/unitfmt.json +1 -1
- package/locale/bg/dateformats.json +1 -1
- package/locale/bg/unitfmt.json +1 -1
- package/locale/bn/sysres.json +1 -1
- package/locale/bn/unitfmt.json +1 -1
- package/locale/bs/Cyrl/ctrynames.json +1 -1
- package/locale/bs/Cyrl/ctryreverse.json +1 -1
- package/locale/bs/Cyrl/unitfmt.json +1 -1
- package/locale/bs/Latn/ctrynames.json +1 -1
- package/locale/bs/Latn/ctryreverse.json +1 -1
- package/locale/bs/ctrynames.json +1 -1
- package/locale/bs/ctryreverse.json +1 -1
- package/locale/bs/dateformats.json +1 -1
- package/locale/bs/localeinfo.json +1 -1
- package/locale/bs/sysres.json +1 -1
- package/locale/bs/unitfmt.json +1 -1
- package/locale/ca/AD/ctrynames.json +1 -1
- package/locale/ca/AD/ctryreverse.json +1 -1
- package/locale/ca/ES/ctrynames.json +1 -1
- package/locale/ca/ES/ctryreverse.json +1 -1
- package/locale/ca/FR/ctrynames.json +1 -1
- package/locale/ca/FR/ctryreverse.json +1 -1
- package/locale/ca/IT/ctrynames.json +1 -1
- package/locale/ca/IT/ctryreverse.json +1 -1
- package/locale/ca/ctrynames.json +1 -1
- package/locale/ca/ctryreverse.json +1 -1
- package/locale/ca/dateformats.json +1 -1
- package/locale/ca/sysres.json +1 -1
- package/locale/ca/unitfmt.json +1 -1
- package/locale/cs/sysres.json +1 -1
- package/locale/cs/unitfmt.json +1 -1
- package/locale/ctype.json +1 -1
- package/locale/ctype_c.json +1 -1
- package/locale/ctype_l.json +1 -1
- package/locale/ctype_s.json +1 -1
- package/locale/currency.json +1 -1
- package/locale/da/dateformats.json +1 -1
- package/locale/da/sysres.json +1 -1
- package/locale/da/unitfmt.json +1 -1
- package/locale/de/CH/sysres.json +1 -1
- package/locale/de/CH/unitfmt.json +1 -1
- package/locale/de/sysres.json +1 -1
- package/locale/de/unitfmt.json +1 -1
- package/locale/el/ctrynames.json +1 -1
- package/locale/el/ctryreverse.json +1 -1
- package/locale/el/unitfmt.json +1 -1
- package/locale/en/001/unitfmt.json +1 -1
- package/locale/en/150/unitfmt.json +1 -1
- package/locale/en/AG/unitfmt.json +1 -1
- package/locale/en/AI/unitfmt.json +1 -1
- package/locale/en/AT/unitfmt.json +1 -1
- package/locale/en/AU/dateformats.json +1 -1
- package/locale/en/AU/sysres.json +1 -1
- package/locale/en/AU/unitfmt.json +1 -1
- package/locale/en/BB/unitfmt.json +1 -1
- package/locale/en/BE/unitfmt.json +1 -1
- package/locale/en/BM/unitfmt.json +1 -1
- package/locale/en/BS/unitfmt.json +1 -1
- package/locale/en/BW/unitfmt.json +1 -1
- package/locale/en/BZ/unitfmt.json +1 -1
- package/locale/en/CA/ctrynames.json +1 -1
- package/locale/en/CA/ctryreverse.json +1 -1
- package/locale/en/CA/unitfmt.json +1 -1
- package/locale/en/CC/unitfmt.json +1 -1
- package/locale/en/CH/unitfmt.json +1 -1
- package/locale/en/CK/unitfmt.json +1 -1
- package/locale/en/CM/unitfmt.json +1 -1
- package/locale/en/CX/unitfmt.json +1 -1
- package/locale/en/CY/unitfmt.json +1 -1
- package/locale/en/DE/unitfmt.json +1 -1
- package/locale/en/DG/unitfmt.json +1 -1
- package/locale/en/DK/unitfmt.json +1 -1
- package/locale/en/DM/unitfmt.json +1 -1
- package/locale/en/Dsrt/ctrynames.json +1 -1
- package/locale/en/Dsrt/ctryreverse.json +1 -1
- package/locale/en/Dsrt/unitfmt.json +1 -1
- package/locale/en/ER/unitfmt.json +1 -1
- package/locale/en/FI/unitfmt.json +1 -1
- package/locale/en/FJ/unitfmt.json +1 -1
- package/locale/en/FK/unitfmt.json +1 -1
- package/locale/en/FM/unitfmt.json +1 -1
- package/locale/en/GB/dateformats.json +1 -1
- package/locale/en/GB/unitfmt.json +1 -1
- package/locale/en/GD/unitfmt.json +1 -1
- package/locale/en/GG/unitfmt.json +1 -1
- package/locale/en/GH/unitfmt.json +1 -1
- package/locale/en/GI/unitfmt.json +1 -1
- package/locale/en/GM/unitfmt.json +1 -1
- package/locale/en/GY/unitfmt.json +1 -1
- package/locale/en/HK/unitfmt.json +1 -1
- package/locale/en/ID/ctrynames.json +1 -0
- package/locale/en/ID/ctryreverse.json +1 -0
- package/locale/en/ID/dateformats.json +1 -0
- package/locale/en/ID/list.json +1 -0
- package/locale/en/ID/localeinfo.json +1 -0
- package/locale/en/ID/sysres.json +1 -0
- package/locale/en/ID/unitfmt.json +1 -0
- package/locale/en/IE/unitfmt.json +1 -1
- package/locale/en/IL/unitfmt.json +1 -1
- package/locale/en/IM/unitfmt.json +1 -1
- package/locale/en/IN/dateformats.json +1 -1
- package/locale/en/IN/unitfmt.json +1 -1
- package/locale/en/IO/unitfmt.json +1 -1
- package/locale/en/JE/unitfmt.json +1 -1
- package/locale/en/JM/unitfmt.json +1 -1
- package/locale/en/KE/unitfmt.json +1 -1
- package/locale/en/KI/unitfmt.json +1 -1
- package/locale/en/KN/unitfmt.json +1 -1
- package/locale/en/KY/unitfmt.json +1 -1
- package/locale/en/LC/unitfmt.json +1 -1
- package/locale/en/LR/unitfmt.json +1 -1
- package/locale/en/LS/unitfmt.json +1 -1
- package/locale/en/MG/unitfmt.json +1 -1
- package/locale/en/MO/unitfmt.json +1 -1
- package/locale/en/MS/unitfmt.json +1 -1
- package/locale/en/MT/unitfmt.json +1 -1
- package/locale/en/MU/unitfmt.json +1 -1
- package/locale/en/MV/dateformats.json +1 -1
- package/locale/en/MV/unitfmt.json +1 -1
- package/locale/en/MW/unitfmt.json +1 -1
- package/locale/en/MY/unitfmt.json +1 -1
- package/locale/en/NA/unitfmt.json +1 -1
- package/locale/en/NF/unitfmt.json +1 -1
- package/locale/en/NG/unitfmt.json +1 -1
- package/locale/en/NL/unitfmt.json +1 -1
- package/locale/en/NR/unitfmt.json +1 -1
- package/locale/en/NU/unitfmt.json +1 -1
- package/locale/en/NZ/dateformats.json +1 -1
- package/locale/en/NZ/unitfmt.json +1 -1
- package/locale/en/PG/unitfmt.json +1 -1
- package/locale/en/PK/unitfmt.json +1 -1
- package/locale/en/PN/unitfmt.json +1 -1
- package/locale/en/PW/unitfmt.json +1 -1
- package/locale/en/RW/unitfmt.json +1 -1
- package/locale/en/SB/unitfmt.json +1 -1
- package/locale/en/SC/unitfmt.json +1 -1
- package/locale/en/SD/unitfmt.json +1 -1
- package/locale/en/SE/unitfmt.json +1 -1
- package/locale/en/SG/unitfmt.json +1 -1
- package/locale/en/SH/unitfmt.json +1 -1
- package/locale/en/SI/unitfmt.json +1 -1
- package/locale/en/SL/unitfmt.json +1 -1
- package/locale/en/SS/unitfmt.json +1 -1
- package/locale/en/SX/unitfmt.json +1 -1
- package/locale/en/SZ/unitfmt.json +1 -1
- package/locale/en/Shaw/unitfmt.json +1 -1
- package/locale/en/TC/unitfmt.json +1 -1
- package/locale/en/TK/unitfmt.json +1 -1
- package/locale/en/TO/unitfmt.json +1 -1
- package/locale/en/TT/unitfmt.json +1 -1
- package/locale/en/TV/unitfmt.json +1 -1
- package/locale/en/TZ/unitfmt.json +1 -1
- package/locale/en/UG/unitfmt.json +1 -1
- package/locale/en/VC/unitfmt.json +1 -1
- package/locale/en/VG/unitfmt.json +1 -1
- package/locale/en/VU/unitfmt.json +1 -1
- package/locale/en/WS/unitfmt.json +1 -1
- package/locale/en/ZA/unitfmt.json +1 -1
- package/locale/en/ZM/unitfmt.json +1 -1
- package/locale/en/ZW/unitfmt.json +1 -1
- package/locale/en/unitfmt.json +1 -1
- package/locale/es/419/ctrynames.json +1 -1
- package/locale/es/419/ctryreverse.json +1 -1
- package/locale/es/419/dateformats.json +1 -1
- package/locale/es/419/localeinfo.json +1 -1
- package/locale/es/419/sysres.json +1 -1
- package/locale/es/419/unitfmt.json +1 -1
- package/locale/es/AR/ctrynames.json +1 -1
- package/locale/es/AR/ctryreverse.json +1 -1
- package/locale/es/AR/dateformats.json +1 -1
- package/locale/es/AR/localeinfo.json +1 -1
- package/locale/es/AR/sysres.json +1 -1
- package/locale/es/AR/unitfmt.json +1 -1
- package/locale/es/BO/ctrynames.json +1 -1
- package/locale/es/BO/ctryreverse.json +1 -1
- package/locale/es/BO/dateformats.json +1 -1
- package/locale/es/BO/localeinfo.json +1 -1
- package/locale/es/BO/sysres.json +1 -1
- package/locale/es/BO/unitfmt.json +1 -1
- package/locale/es/BR/ctrynames.json +1 -1
- package/locale/es/BR/ctryreverse.json +1 -1
- package/locale/es/BR/localeinfo.json +1 -1
- package/locale/es/BR/sysres.json +1 -1
- package/locale/es/BR/unitfmt.json +1 -1
- package/locale/es/BZ/ctrynames.json +1 -1
- package/locale/es/BZ/ctryreverse.json +1 -1
- package/locale/es/BZ/localeinfo.json +1 -1
- package/locale/es/BZ/sysres.json +1 -1
- package/locale/es/BZ/unitfmt.json +1 -1
- package/locale/es/CL/ctrynames.json +1 -1
- package/locale/es/CL/ctryreverse.json +1 -1
- package/locale/es/CL/dateformats.json +1 -1
- package/locale/es/CL/localeinfo.json +1 -1
- package/locale/es/CL/sysres.json +1 -1
- package/locale/es/CL/unitfmt.json +1 -1
- package/locale/es/CO/ctrynames.json +1 -1
- package/locale/es/CO/ctryreverse.json +1 -1
- package/locale/es/CO/localeinfo.json +1 -1
- package/locale/es/CO/sysres.json +1 -1
- package/locale/es/CO/unitfmt.json +1 -1
- package/locale/es/CR/ctrynames.json +1 -1
- package/locale/es/CR/ctryreverse.json +1 -1
- package/locale/es/CR/dateformats.json +1 -1
- package/locale/es/CR/localeinfo.json +1 -1
- package/locale/es/CR/sysres.json +1 -1
- package/locale/es/CR/unitfmt.json +1 -1
- package/locale/es/CU/ctrynames.json +1 -1
- package/locale/es/CU/ctryreverse.json +1 -1
- package/locale/es/CU/dateformats.json +1 -1
- package/locale/es/CU/localeinfo.json +1 -1
- package/locale/es/CU/sysres.json +1 -1
- package/locale/es/CU/unitfmt.json +1 -1
- package/locale/es/DO/ctrynames.json +1 -1
- package/locale/es/DO/ctryreverse.json +1 -1
- package/locale/es/DO/localeinfo.json +1 -1
- package/locale/es/DO/sysres.json +1 -1
- package/locale/es/DO/unitfmt.json +1 -1
- package/locale/es/EC/ctrynames.json +1 -1
- package/locale/es/EC/ctryreverse.json +1 -1
- package/locale/es/EC/dateformats.json +1 -1
- package/locale/es/EC/localeinfo.json +1 -1
- package/locale/es/EC/sysres.json +1 -1
- package/locale/es/EC/unitfmt.json +1 -1
- package/locale/es/GT/ctrynames.json +1 -1
- package/locale/es/GT/ctryreverse.json +1 -1
- package/locale/es/GT/dateformats.json +1 -1
- package/locale/es/GT/localeinfo.json +1 -1
- package/locale/es/GT/sysres.json +1 -1
- package/locale/es/GT/unitfmt.json +1 -1
- package/locale/es/HN/ctrynames.json +1 -1
- package/locale/es/HN/ctryreverse.json +1 -1
- package/locale/es/HN/dateformats.json +1 -1
- package/locale/es/HN/localeinfo.json +1 -1
- package/locale/es/HN/sysres.json +1 -1
- package/locale/es/HN/unitfmt.json +1 -1
- package/locale/es/MX/ctrynames.json +1 -1
- package/locale/es/MX/ctryreverse.json +1 -1
- package/locale/es/MX/dateformats.json +1 -1
- package/locale/es/MX/localeinfo.json +1 -1
- package/locale/es/MX/sysres.json +1 -1
- package/locale/es/MX/unitfmt.json +1 -1
- package/locale/es/NI/ctrynames.json +1 -1
- package/locale/es/NI/ctryreverse.json +1 -1
- package/locale/es/NI/dateformats.json +1 -1
- package/locale/es/NI/localeinfo.json +1 -1
- package/locale/es/NI/sysres.json +1 -1
- package/locale/es/NI/unitfmt.json +1 -1
- package/locale/es/PA/ctrynames.json +1 -1
- package/locale/es/PA/ctryreverse.json +1 -1
- package/locale/es/PA/localeinfo.json +1 -1
- package/locale/es/PA/sysres.json +1 -1
- package/locale/es/PA/unitfmt.json +1 -1
- package/locale/es/PE/ctrynames.json +1 -1
- package/locale/es/PE/ctryreverse.json +1 -1
- package/locale/es/PE/dateformats.json +1 -1
- package/locale/es/PE/localeinfo.json +1 -1
- package/locale/es/PE/sysres.json +1 -1
- package/locale/es/PE/unitfmt.json +1 -1
- package/locale/es/PR/ctrynames.json +1 -1
- package/locale/es/PR/ctryreverse.json +1 -1
- package/locale/es/PR/localeinfo.json +1 -1
- package/locale/es/PR/sysres.json +1 -1
- package/locale/es/PR/unitfmt.json +1 -1
- package/locale/es/PY/ctrynames.json +1 -1
- package/locale/es/PY/ctryreverse.json +1 -1
- package/locale/es/PY/dateformats.json +1 -1
- package/locale/es/PY/localeinfo.json +1 -1
- package/locale/es/PY/sysres.json +1 -1
- package/locale/es/PY/unitfmt.json +1 -1
- package/locale/es/SV/ctrynames.json +1 -1
- package/locale/es/SV/ctryreverse.json +1 -1
- package/locale/es/SV/dateformats.json +1 -1
- package/locale/es/SV/localeinfo.json +1 -1
- package/locale/es/SV/sysres.json +1 -1
- package/locale/es/SV/unitfmt.json +1 -1
- package/locale/es/US/ctrynames.json +1 -1
- package/locale/es/US/ctryreverse.json +1 -1
- package/locale/es/US/localeinfo.json +1 -1
- package/locale/es/US/sysres.json +1 -1
- package/locale/es/US/unitfmt.json +1 -1
- package/locale/es/UY/ctrynames.json +1 -1
- package/locale/es/UY/ctryreverse.json +1 -1
- package/locale/es/UY/dateformats.json +1 -1
- package/locale/es/UY/localeinfo.json +1 -1
- package/locale/es/UY/sysres.json +1 -1
- package/locale/es/UY/unitfmt.json +1 -1
- package/locale/es/VE/ctrynames.json +1 -1
- package/locale/es/VE/ctryreverse.json +1 -1
- package/locale/es/VE/localeinfo.json +1 -1
- package/locale/es/VE/sysres.json +1 -1
- package/locale/es/VE/unitfmt.json +1 -1
- package/locale/es/localeinfo.json +1 -1
- package/locale/es/sysres.json +1 -1
- package/locale/es/unitfmt.json +1 -1
- package/locale/et/ctrynames.json +1 -1
- package/locale/et/ctryreverse.json +1 -1
- package/locale/et/sysres.json +1 -1
- package/locale/et/unitfmt.json +1 -1
- package/locale/eu/dateformats.json +1 -1
- package/locale/eu/sysres.json +1 -1
- package/locale/eu/unitfmt.json +1 -1
- package/locale/fa/AF/sysres.json +1 -1
- package/locale/fa/unitfmt.json +1 -1
- package/locale/fi/ctrynames.json +1 -1
- package/locale/fi/ctryreverse.json +1 -1
- package/locale/fi/dateformats.json +1 -1
- package/locale/fi/sysres.json +1 -1
- package/locale/fi/unitfmt.json +1 -1
- package/locale/fr/CA/ctrynames.json +1 -1
- package/locale/fr/CA/ctryreverse.json +1 -1
- package/locale/fr/CA/sysres.json +1 -1
- package/locale/fr/CA/unitfmt.json +1 -1
- package/locale/fr/HT/unitfmt.json +1 -1
- package/locale/fr/unitfmt.json +1 -1
- package/locale/ga/GB/ctrynames.json +1 -1
- package/locale/ga/GB/ctryreverse.json +1 -1
- package/locale/ga/ctrynames.json +1 -1
- package/locale/ga/ctryreverse.json +1 -1
- package/locale/ga/sysres.json +1 -1
- package/locale/ga/unitfmt.json +1 -1
- package/locale/gl/ctrynames.json +1 -1
- package/locale/gl/ctryreverse.json +1 -1
- package/locale/gl/sysres.json +1 -1
- package/locale/gl/unitfmt.json +1 -1
- package/locale/gu/unitfmt.json +1 -1
- package/locale/ha/Arab/SD/unitfmt.json +1 -1
- package/locale/ha/Arab/unitfmt.json +1 -1
- package/locale/ha/GH/ctrynames.json +1 -1
- package/locale/ha/GH/ctryreverse.json +1 -1
- package/locale/ha/NE/ctrynames.json +1 -1
- package/locale/ha/NE/ctryreverse.json +1 -1
- package/locale/ha/ctrynames.json +1 -1
- package/locale/ha/ctryreverse.json +1 -1
- package/locale/ha/regionnames.json +1 -1
- package/locale/ha/unitfmt.json +1 -1
- package/locale/he/sysres.json +1 -1
- package/locale/he/unitfmt.json +1 -1
- package/locale/hi/Latn/dateformats.json +1 -1
- package/locale/hi/Latn/sysres.json +1 -1
- package/locale/hi/Latn/unitfmt.json +1 -1
- package/locale/hi/sysres.json +1 -1
- package/locale/hi/unitfmt.json +1 -1
- package/locale/hr/BA/ctrynames.json +1 -1
- package/locale/hr/BA/ctryreverse.json +1 -1
- package/locale/hr/ctrynames.json +1 -1
- package/locale/hr/ctryreverse.json +1 -1
- package/locale/hr/sysres.json +1 -1
- package/locale/hr/unitfmt.json +1 -1
- package/locale/hu/sysres.json +1 -1
- package/locale/hu/unitfmt.json +1 -1
- package/locale/hy/ctrynames.json +1 -1
- package/locale/hy/ctryreverse.json +1 -1
- package/locale/hy/unitfmt.json +1 -1
- package/locale/id/unitfmt.json +1 -1
- package/locale/ig/unitfmt.json +1 -1
- package/locale/ilibmanifest.json +1 -1
- package/locale/is/sysres.json +1 -1
- package/locale/is/unitfmt.json +1 -1
- package/locale/it/CH/ctrynames.json +1 -1
- package/locale/it/CH/ctryreverse.json +1 -1
- package/locale/it/SM/ctrynames.json +1 -1
- package/locale/it/SM/ctryreverse.json +1 -1
- package/locale/it/VA/ctrynames.json +1 -1
- package/locale/it/VA/ctryreverse.json +1 -1
- package/locale/it/ctrynames.json +1 -1
- package/locale/it/ctryreverse.json +1 -1
- package/locale/it/sysres.json +1 -1
- package/locale/it/unitfmt.json +1 -1
- package/locale/ja/unitfmt.json +1 -1
- package/locale/ka/unitfmt.json +1 -1
- package/locale/kk/unitfmt.json +1 -1
- package/locale/km/localeinfo.json +1 -1
- package/locale/km/unitfmt.json +1 -1
- package/locale/kn/ctrynames.json +1 -1
- package/locale/kn/ctryreverse.json +1 -1
- package/locale/kn/unitfmt.json +1 -1
- package/locale/ko/CN/ctrynames.json +1 -0
- package/locale/ko/CN/ctryreverse.json +1 -0
- package/locale/ko/CN/dateformats.json +1 -0
- package/locale/ko/KP/ctrynames.json +1 -1
- package/locale/ko/KP/ctryreverse.json +1 -1
- package/locale/ko/ctrynames.json +1 -1
- package/locale/ko/ctryreverse.json +1 -1
- package/locale/ko/dateformats.json +1 -1
- package/locale/ko/sysres.json +1 -1
- package/locale/ko/unitfmt.json +1 -1
- package/locale/ku/ctrynames.json +1 -1
- package/locale/ku/ctryreverse.json +1 -1
- package/locale/ku/unitfmt.json +1 -1
- package/locale/ky/unitfmt.json +1 -1
- package/locale/lb/ctrynames.json +1 -1
- package/locale/lb/ctryreverse.json +1 -1
- package/locale/lb/sysres.json +1 -1
- package/locale/lb/unitfmt.json +1 -1
- package/locale/lo/ctrynames.json +1 -1
- package/locale/lo/ctryreverse.json +1 -1
- package/locale/lo/unitfmt.json +1 -1
- package/locale/localematch.json +1 -1
- package/locale/lt/sysres.json +1 -1
- package/locale/lt/unitfmt.json +1 -1
- package/locale/lv/sysres.json +1 -1
- package/locale/lv/unitfmt.json +1 -1
- package/locale/mk/sysres.json +1 -1
- package/locale/mk/unitfmt.json +1 -1
- package/locale/ml/ctrynames.json +1 -1
- package/locale/ml/ctryreverse.json +1 -1
- package/locale/ml/list.json +1 -1
- package/locale/ml/unitfmt.json +1 -1
- package/locale/mn/Mong/MN/unitfmt.json +1 -1
- package/locale/mn/Mong/unitfmt.json +1 -1
- package/locale/mn/unitfmt.json +1 -1
- package/locale/mr/unitfmt.json +1 -1
- package/locale/ms/Arab/BN/unitfmt.json +1 -1
- package/locale/ms/Arab/unitfmt.json +1 -1
- package/locale/ms/unitfmt.json +1 -1
- package/locale/mt/ctrynames.json +1 -1
- package/locale/mt/ctryreverse.json +1 -1
- package/locale/mt/sysres.json +1 -1
- package/locale/mt/unitfmt.json +1 -1
- package/locale/my/list.json +1 -1
- package/locale/my/sysres.json +1 -1
- package/locale/my/unitfmt.json +1 -1
- package/locale/nb/SJ/ctrynames.json +1 -1
- package/locale/nb/SJ/ctryreverse.json +1 -1
- package/locale/nb/ctrynames.json +1 -1
- package/locale/nb/ctryreverse.json +1 -1
- package/locale/nb/localeinfo.json +1 -1
- package/locale/nb/sysres.json +1 -1
- package/locale/nb/unitfmt.json +1 -1
- package/locale/ne/unitfmt.json +1 -1
- package/locale/nl/BE/dateformats.json +1 -1
- package/locale/nl/dateformats.json +1 -1
- package/locale/nl/list.json +1 -1
- package/locale/nl/sysres.json +1 -1
- package/locale/nl/unitfmt.json +1 -1
- package/locale/or/sysres.json +1 -1
- package/locale/or/unitfmt.json +1 -1
- package/locale/pa/Arab/unitfmt.json +1 -1
- package/locale/pa/unitfmt.json +1 -1
- package/locale/pl/unitfmt.json +1 -1
- package/locale/ps/PK/unitfmt.json +1 -1
- package/locale/ps/dateformats.json +1 -1
- package/locale/ps/sysres.json +1 -1
- package/locale/ps/unitfmt.json +1 -1
- package/locale/pt/AO/unitfmt.json +1 -1
- package/locale/pt/CH/unitfmt.json +1 -1
- package/locale/pt/CV/unitfmt.json +1 -1
- package/locale/pt/GQ/unitfmt.json +1 -1
- package/locale/pt/GW/unitfmt.json +1 -1
- package/locale/pt/LU/unitfmt.json +1 -1
- package/locale/pt/MO/unitfmt.json +1 -1
- package/locale/pt/MZ/unitfmt.json +1 -1
- package/locale/pt/PT/unitfmt.json +1 -1
- package/locale/pt/ST/unitfmt.json +1 -1
- package/locale/pt/TL/unitfmt.json +1 -1
- package/locale/pt/sysres.json +1 -1
- package/locale/pt/unitfmt.json +1 -1
- package/locale/rangeToScript.json +1 -1
- package/locale/ro/MD/sysres.json +1 -1
- package/locale/ro/sysres.json +1 -1
- package/locale/ro/unitfmt.json +1 -1
- package/locale/ru/unitfmt.json +1 -1
- package/locale/scriptToRange.json +1 -1
- package/locale/scripts.json +1 -1
- package/locale/si/unitfmt.json +1 -1
- package/locale/sk/sysres.json +1 -1
- package/locale/sk/unitfmt.json +1 -1
- package/locale/sl/dateformats.json +1 -1
- package/locale/sl/sysres.json +1 -1
- package/locale/sl/unitfmt.json +1 -1
- package/locale/sq/sysres.json +1 -1
- package/locale/sq/unitfmt.json +1 -1
- package/locale/sr/Cyrl/BA/sysres.json +1 -1
- package/locale/sr/Cyrl/BA/unitfmt.json +1 -1
- package/locale/sr/Cyrl/ME/sysres.json +1 -1
- package/locale/sr/Cyrl/XK/sysres.json +1 -1
- package/locale/sr/Latn/BA/sysres.json +1 -1
- package/locale/sr/Latn/BA/unitfmt.json +1 -1
- package/locale/sr/Latn/ME/sysres.json +1 -1
- package/locale/sr/Latn/ME/unitfmt.json +1 -1
- package/locale/sr/Latn/XK/sysres.json +1 -1
- package/locale/sr/Latn/XK/unitfmt.json +1 -1
- package/locale/sr/Latn/unitfmt.json +1 -1
- package/locale/sr/sysres.json +1 -1
- package/locale/sr/unitfmt.json +1 -1
- package/locale/sv/AX/ctrynames.json +1 -1
- package/locale/sv/AX/ctryreverse.json +1 -1
- package/locale/sv/FI/ctrynames.json +1 -1
- package/locale/sv/FI/ctryreverse.json +1 -1
- package/locale/sv/ctrynames.json +1 -1
- package/locale/sv/ctryreverse.json +1 -1
- package/locale/sv/sysres.json +1 -1
- package/locale/sv/unitfmt.json +1 -1
- package/locale/sw/KE/ctrynames.json +1 -1
- package/locale/sw/KE/ctryreverse.json +1 -1
- package/locale/sw/KE/unitfmt.json +1 -1
- package/locale/sw/unitfmt.json +1 -1
- package/locale/ta/sysres.json +1 -1
- package/locale/ta/unitfmt.json +1 -1
- package/locale/te/unitfmt.json +1 -1
- package/locale/tg/localeinfo.json +1 -1
- package/locale/tg/unitfmt.json +1 -1
- package/locale/th/unitfmt.json +1 -1
- package/locale/tk/sysres.json +1 -1
- package/locale/tk/unitfmt.json +1 -1
- package/locale/tr/CY/ctrynames.json +1 -1
- package/locale/tr/CY/ctryreverse.json +1 -1
- package/locale/tr/ctrynames.json +1 -1
- package/locale/tr/ctryreverse.json +1 -1
- package/locale/tr/unitfmt.json +1 -1
- package/locale/uk/ctrynames.json +1 -1
- package/locale/uk/ctryreverse.json +1 -1
- package/locale/uk/dateformats.json +1 -1
- package/locale/uk/sysres.json +1 -1
- package/locale/uk/unitfmt.json +1 -1
- package/locale/und/AR/localeinfo.json +1 -1
- package/locale/und/BO/localeinfo.json +1 -1
- package/locale/und/CL/localeinfo.json +1 -1
- package/locale/und/CR/localeinfo.json +1 -1
- package/locale/und/EC/localeinfo.json +1 -1
- package/locale/und/GT/localeinfo.json +1 -1
- package/locale/und/HN/localeinfo.json +1 -1
- package/locale/und/MX/localeinfo.json +1 -1
- package/locale/und/NI/localeinfo.json +1 -1
- package/locale/und/PE/localeinfo.json +1 -1
- package/locale/und/PY/localeinfo.json +1 -1
- package/locale/und/SV/localeinfo.json +1 -1
- package/locale/und/UY/localeinfo.json +1 -1
- package/locale/unitfmt.json +1 -1
- package/locale/ur/IN/ctrynames.json +1 -1
- package/locale/ur/IN/ctryreverse.json +1 -1
- package/locale/ur/IN/unitfmt.json +1 -1
- package/locale/ur/unitfmt.json +1 -1
- package/locale/uz/Arab/sysres.json +1 -1
- package/locale/uz/Arab/unitfmt.json +1 -1
- package/locale/uz/Cyrl/ctrynames.json +1 -1
- package/locale/uz/Cyrl/ctryreverse.json +1 -1
- package/locale/uz/Cyrl/unitfmt.json +1 -1
- package/locale/uz/sysres.json +1 -1
- package/locale/uz/unitfmt.json +1 -1
- package/locale/vi/dateformats.json +1 -1
- package/locale/vi/sysres.json +1 -1
- package/locale/vi/unitfmt.json +1 -1
- package/locale/wo/ctrynames.json +1 -1
- package/locale/wo/ctryreverse.json +1 -1
- package/locale/wo/unitfmt.json +1 -1
- package/locale/yo/BJ/ctrynames.json +1 -1
- package/locale/yo/BJ/ctryreverse.json +1 -1
- package/locale/yo/BJ/unitfmt.json +1 -1
- package/locale/yo/ctrynames.json +1 -1
- package/locale/yo/ctryreverse.json +1 -1
- package/locale/yo/unitfmt.json +1 -1
- package/locale/zh/Hans/HK/unitfmt.json +1 -1
- package/locale/zh/Hans/MO/unitfmt.json +1 -1
- package/locale/zh/Hans/SG/unitfmt.json +1 -1
- package/locale/zh/Hant/HK/unitfmt.json +1 -1
- package/locale/zh/Hant/MO/unitfmt.json +1 -1
- package/locale/zh/Hant/list.json +1 -1
- package/locale/zh/Hant/unitfmt.json +1 -1
- package/locale/zh/unitfmt.json +1 -1
- package/locale/zoneinfo/Africa/Casablanca.json +1 -1
- package/locale/zoneinfo/Africa/El_Aaiun.json +1 -1
- package/locale/zoneinfo/America/Bahia_Banderas.json +1 -1
- package/locale/zoneinfo/America/Chihuahua.json +1 -1
- package/locale/zoneinfo/America/Ciudad_Juarez.json +1 -1
- package/locale/zoneinfo/America/Ensenada.json +1 -1
- package/locale/zoneinfo/America/Mazatlan.json +1 -1
- package/locale/zoneinfo/America/Merida.json +1 -1
- package/locale/zoneinfo/America/Mexico_City.json +1 -1
- package/locale/zoneinfo/America/Monterrey.json +1 -1
- package/locale/zoneinfo/America/Ojinaga.json +1 -1
- package/locale/zoneinfo/America/Scoresbysund.json +1 -1
- package/locale/zoneinfo/Antarctica/Casey.json +1 -1
- package/locale/zoneinfo/Antarctica/Vostok.json +1 -1
- package/locale/zoneinfo/Asia/Almaty.json +1 -1
- package/locale/zoneinfo/Asia/Gaza.json +1 -1
- package/locale/zoneinfo/Asia/Hebron.json +1 -1
- package/locale/zoneinfo/Asia/Qostanay.json +1 -1
- package/locale/zoneinfo/Asia/Tehran.json +1 -1
- package/locale/zoneinfo/Mexico/BajaSur.json +1 -1
- package/locale/zoneinfo/Mexico/General.json +1 -1
- package/locale/zu/sysres.json +1 -1
- package/locale/zu/unitfmt.json +1 -1
- package/package.json +1 -1
package/lib/Address.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// !data address countries nativecountries ctrynames
|
|
2
|
-
var ilib=require("../index.js"),Utils=require("./Utils.js"),JSUtils=require("./JSUtils.js"),Locale=require("./Locale.js"),CType=require("./CType.js"),isIdeo=require("./isIdeo.js"),isAscii=require("./isAscii.js"),isDigit=require("./isDigit.js"),IString=require("./IString.js"),Address=function(freeformAddress,options){
|
|
2
|
+
var ilib=require("../index.js"),Utils=require("./Utils.js"),JSUtils=require("./JSUtils.js"),Locale=require("./Locale.js"),CType=require("./CType.js"),isIdeo=require("./isIdeo.js"),isAscii=require("./isAscii.js"),isDigit=require("./isDigit.js"),IString=require("./IString.js"),Address=function(freeformAddress,options){if(freeformAddress){if(this.sync=!0,this.loadParams={},options&&(options.locale&&(this.locale="string"==typeof options.locale?new Locale(options.locale):options.locale),void 0!==options.sync&&(this.sync=!!options.sync),options.loadParams)&&(this.loadParams=options.loadParams),this.locale=this.locale||new Locale(),"object"==typeof freeformAddress)return this.streetAddress=freeformAddress.streetAddress,this.locality=freeformAddress.locality,this.region=freeformAddress.region,this.postalCode=freeformAddress.postalCode,this.postOffice=freeformAddress.postOffice,this.country=freeformAddress.country,freeformAddress.countryCode&&(this.countryCode=freeformAddress.countryCode),freeformAddress.format&&(this.format=freeformAddress.format),this;freeformAddress=(freeformAddress=(freeformAddress=freeformAddress.replace(/[ \t\r]+/g," ").trim()).replace(/[\s\n]+$/,"")).replace(/^[\s\n]+/,""),this.lines=freeformAddress.split(/[,,\n]/g),this.removeEmptyLines(this.lines),isAscii._init(this.sync,this.loadParams,ilib.bind(this,function(){isIdeo._init(this.sync,this.loadParams,ilib.bind(this,function(){isDigit._init(this.sync,this.loadParams,ilib.bind(this,function(){void 0===ilib.data.nativecountries?Utils.loadData({object:"Address",name:"nativecountries.json",locale:"-",nonlocale:!0,sync:this.sync,loadParams:this.loadParams,callback:ilib.bind(this,function(nativecountries){ilib.data.nativecountries=nativecountries,this._loadCountries(options&&options.onLoad)})}):this._loadCountries(options&&options.onLoad)}))}))}))}};Address.prototype={_loadCountries:function(onLoad){void 0===ilib.data.countries?Utils.loadData({object:"Address",name:"countries.json",locale:"-",nonlocale:!0,sync:this.sync,loadParams:this.loadParams,callback:ilib.bind(this,function(countries){ilib.data.countries=countries,this._loadCtrynames(onLoad)})}):this._loadCtrynames(onLoad)},_loadCtrynames:function(onLoad){Utils.loadData({name:"ctrynames.json",object:"Address",locale:this.locale,sync:this.sync,loadParams:JSUtils.merge(this.loadParams,{returnOne:!0}),callback:ilib.bind(this,function(ctrynames){this.ctrynames=ctrynames,this._determineDest(ctrynames,onLoad)})})},_findDest:function(ctrynames){var match,countryName,temp;for(countryName in ctrynames)countryName&&"generated"!==countryName&&(!match||match.text.length<countryName.length)&&(temp=this._findCountry(countryName))&&(this.country=(match=temp).text,this.countryCode=ctrynames[countryName]);return match},_determineDest:function(localizedCountries,callback){var match,tables=[];localizedCountries&&tables.push(localizedCountries),tables.push(ilib.data.nativecountries),tables.push(ilib.data.countries);for(var i=0;i<tables.length;i++)if(match=this._findDest(tables[i]))return this.lines[match.line]=this.lines[match.line].substring(0,match.start)+this.lines[match.line].substring(match.start+match.text.length),void this._init(callback);this.country=void 0,this.countryCode=this.locale.getRegion(),this._init(callback)},_init:function(callback){Utils.loadData({object:"Address",locale:new Locale(this.countryCode),name:"address.json",sync:this.sync,loadParams:this.loadParams,callback:ilib.bind(this,function(info){info&&!JSUtils.isEmpty(info)&&info.fields?(this.info=info,this._parseAddress(),"function"==typeof callback&&callback(this)):Utils.loadData({object:"Address",locale:new Locale("XX"),name:"address.json",sync:this.sync,loadParams:this.loadParams,callback:ilib.bind(this,function(info){this.info=info,this._parseAddress(),"function"==typeof callback&&callback(this)})})})})},_parseAddress:function(){var i,startAt,infoFields,field,pattern,matchFunction,match,fieldNumber,joinString,asianChars=0,latinChars=0;if(this.info&&this.info.multiformat){for(var j=0;j<this.lines.length;j++)for(var it=new IString(this.lines[j]).charIterator();it.hasNext();){var c=it.next();isIdeo(c)||CType.withinRange(c,"hangul")||CType.withinRange(c,"katakana")||CType.withinRange(c,"hiragana")||CType.withinRange(c,"bopomofo")?asianChars++:isAscii(c)&&!isDigit(c)&&latinChars++}this.format=latinChars<=asianChars?"asian":"latin",startAt=this.info.startAt[this.format],infoFields=this.info.fields[this.format]}else startAt=this.info&&this.info.startAt||"end",infoFields=this.info&&this.info.fields||[];for(this.compare="end"===startAt?this.endsWith:this.startsWith,i=0;i<infoFields.length&&0<this.lines.length;i++)if(field=infoFields[i],this.removeEmptyLines(this.lines),field.pattern){switch(matchFunction="string"==typeof field.pattern?(pattern=new RegExp(field.pattern,"img"),this.matchRegExp):(pattern=field.pattern,this.matchPattern),field.line){case"startAtFirst":for(fieldNumber=0;fieldNumber<this.lines.length&&!(match=matchFunction(this,this.lines[fieldNumber],pattern,field.matchGroup,startAt));fieldNumber++);break;case"startAtLast":for(fieldNumber=this.lines.length-1;0<=fieldNumber&&!(match=matchFunction(this,this.lines[fieldNumber],pattern,field.matchGroup,startAt));fieldNumber--);break;case"first":match=matchFunction(this,this.lines[fieldNumber=0],pattern,field.matchGroup,startAt);break;default:fieldNumber=this.lines.length-1,match=matchFunction(this,this.lines[fieldNumber],pattern,field.matchGroup,startAt)}match&&(this.lines[fieldNumber]=match.line,this[field.name]=match.match)}else this[field.name]=this.lines.splice(fieldNumber,1)[0].trim();this.removeEmptyLines(this.lines),0<this.lines.length&&(joinString=this.info.joinString&&this.info.joinString[this.format]||(this.format&&"asian"===this.format?"":", "),this.streetAddress=this.lines.join(joinString).trim()),this.lines=void 0},_findCountry:function(name){var match,start=-1,line=0;return match=0<this.lines.length&&(-1===(start=this.startsWith(this.lines[line],name))&&(line=this.lines.length-1,start=this.endsWith(this.lines[line],name)),-1!==start)?{text:this.lines[line].substring(start,start+name.length),line:line,start:start}:match},endsWith:function(subject,query){for(var start=subject.length-query.length,i=0;i<query.length;i++)if(subject.charAt(start+i).toLowerCase()!==query.charAt(i).toLowerCase())return-1;return 0<start&&!/\s/.test(subject.charAt(start-1))?-1:start},startsWith:function(subject,query){for(var i=0;i<query.length;i++)if(subject.charAt(i).toLowerCase()!==query.charAt(i).toLowerCase())return-1;return 0},removeEmptyLines:function(arr){for(var i=0;i<arr.length;)!arr[i]||(arr[i]=arr[i].trim(),0===arr[i].length)?arr.splice(i,1):i++},matchRegExp:function(address,line,expression,matchGroup,startAt){var lastMatch,ret={},match=expression.exec(line);if("end"===startAt){for(;null!==match&&0<match.length;)lastMatch=match,match=expression.exec(line);match=lastMatch}if(match&&null!==match&&void 0!==match[matchGroup=matchGroup||0])return ret.match=match[matchGroup].trim(),ret.match=ret.match.replace(/^\-|\-+$/,""),ret.match=ret.match.replace(/\s+$/,""),startAt="end"===startAt?line.lastIndexOf(match[matchGroup]):line.indexOf(match[matchGroup]),ret.line=line.slice(0,startAt),"asian"!==address.format&&(ret.line+=" "),ret.line+=line.slice(startAt+match[matchGroup].length),ret.line=ret.line.trim(),ret},matchPattern:function(address,line,pattern,matchGroup){for(var start,ret={},j=0;j<pattern.length;j++)if(-1!==(start=address.compare(line,pattern[j])))return ret.match=line.substring(start,start+pattern[j].length),ret.line=(0!==start?line.substring(0,start):line.substring(pattern[j].length)).trim(),ret}},module.exports=Address;
|
package/lib/AddressFmt.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// !data address addressres regionnames
|
|
2
|
-
var ilib=require("../index.js"),Utils=require("./Utils.js"),JSUtils=require("./JSUtils.js"),Locale=require("./Locale.js"),Address=require("./Address.js"),IString=require("./IString.js"),ResBundle=require("./ResBundle.js"),defaultData={formats:{default:"{streetAddress}\n{locality} {region} {postalCode}\n{country}",nocountry:"{streetAddress}\n{locality} {region} {postalCode}"},startAt:"end",fields:[{name:"postalCode",line:"startAtLast",pattern:"[0-9]+",matchGroup:0},{name:"region",line:"last",pattern:"([A-zÀÁÈÉÌÍÑÒÓÙÚÜàáèéìíñòóùúü\\.\\-\\']+\\s*){1,2}$",matchGroup:0},{name:"locality",line:"last",pattern:"([A-zÀÁÈÉÌÍÑÒÓÙÚÜàáèéìíñòóùúü\\.\\-\\']+\\s*){1,2}$",matchGroup:0}],fieldNames:{streetAddress:"Street Address",locality:"City",postalCode:"Zip Code",region:"State",country:"Country"}},AddressFmt=function(options){this.sync=!0,this.styleName="default",this.loadParams={},this.locale=new Locale(),options&&(options.locale&&(this.locale="string"==typeof options.locale?new Locale(options.locale):options.locale),void 0!==options.sync&&(this.sync=!!options.sync),options.style&&(this.styleName=options.style),options.loadParams&&(this.loadParams=options.loadParams)
|
|
2
|
+
var ilib=require("../index.js"),Utils=require("./Utils.js"),JSUtils=require("./JSUtils.js"),Locale=require("./Locale.js"),Address=require("./Address.js"),IString=require("./IString.js"),ResBundle=require("./ResBundle.js"),defaultData={formats:{default:"{streetAddress}\n{locality} {region} {postalCode}\n{country}",nocountry:"{streetAddress}\n{locality} {region} {postalCode}"},startAt:"end",fields:[{name:"postalCode",line:"startAtLast",pattern:"[0-9]+",matchGroup:0},{name:"region",line:"last",pattern:"([A-zÀÁÈÉÌÍÑÒÓÙÚÜàáèéìíñòóùúü\\.\\-\\']+\\s*){1,2}$",matchGroup:0},{name:"locality",line:"last",pattern:"([A-zÀÁÈÉÌÍÑÒÓÙÚÜàáèéìíñòóùúü\\.\\-\\']+\\s*){1,2}$",matchGroup:0}],fieldNames:{streetAddress:"Street Address",locality:"City",postalCode:"Zip Code",region:"State",country:"Country"}},AddressFmt=function(options){this.sync=!0,this.styleName="default",this.loadParams={},this.locale=new Locale(),options&&(options.locale&&(this.locale="string"==typeof options.locale?new Locale(options.locale):options.locale),void 0!==options.sync&&(this.sync=!!options.sync),options.style&&(this.styleName=options.style),options.loadParams)&&(this.loadParams=options.loadParams),Utils.loadData({name:"address.json",object:"AddressFmt",locale:this.locale,sync:this.sync,loadParams:this.loadParams,callback:ilib.bind(this,function(info){!info||JSUtils.isEmpty(info)?Utils.loadData({name:"address.json",object:"AddressFmt",locale:new Locale("XX"),sync:this.sync,loadParams:this.loadParams,callback:ilib.bind(this,function(info){this.info=info,this._init(),options&&"function"==typeof options.onLoad&&options.onLoad(this)})}):(this.info=info,this._init(),options&&"function"==typeof options.onLoad&&options.onLoad(this))})})};function isAsianLocale(locale){return"zh"===locale.language||"ja"===locale.language||"ko"===locale.language}function invertAndFilter(object){var p,ret=[],regions=["AQ","EU","EZ","UN","ZZ"];for(p in object)p&&!object[p].match(/\d/)&&-1===regions.indexOf(object[p])&&ret.push({code:object[p],name:p});return ret}AddressFmt.prototype._init=function(){this.info||(this.info=defaultData),this.style=this.info.formats&&this.info.formats[this.styleName],this.style=this.style||this.info.formats&&this.info.formats.default||defaultData.formats.default,this.info.fieldNames||(this.info.fieldNames=defaultData.fieldNames)},AddressFmt.prototype.format=function(address){var format;return address?address.countryCode&&address.countryCode!==this.locale.region&&Locale._isRegionCode(this.locale.region)&&"XX"!==this.locale.region?new AddressFmt({locale:new Locale(address.countryCode),style:this.styleName}).format(address):(format="object"==typeof this.style?this.style[address.format||"latin"]:this.style,address={country:address.country||"",region:address.region||"",locality:address.locality||"",streetAddress:address.streetAddress||"",postalCode:address.postalCode||"",postOffice:address.postOffice||""},new IString(format).format(address).replace(/[ \t]+/g," ").replace("\n ","\n").replace(" \n","\n").replace(/\n+/g,"\n").trim()):""},AddressFmt.prototype.getFormatInfo=function(locale,sync,callback){var info,loc=new Locale(this.locale);return locale&&("string"==typeof locale&&(locale=new Locale(locale)),loc.language=locale.getLanguage(),loc.spec=void 0),Utils.loadData({name:"regionnames.json",object:"AddressFmt",locale:loc,sync:this.sync,loadParams:JSUtils.merge(this.loadParams,{returnOne:!0},!0),callback:ilib.bind(this,function(regions){this.regions=regions,new ResBundle({locale:loc,name:"addressres",sync:this.sync,loadParams:this.loadParams,onLoad:ilib.bind(this,function(rb){var type,format,fields=this.info.fields||defaultData.fields;this.info.multiformat&&(type=isAsianLocale(this.locale)?"asian":"latin",fields=this.info.fields[type]),format="object"==typeof this.style?this.style[type||"latin"]:this.style,new Address(" ",{locale:loc,sync:this.sync,loadParams:this.loadParams,onLoad:ilib.bind(this,function(localeAddress){var rows=format.split(/\n/g);info=rows.map(ilib.bind(this,function(row){return row.split("}").filter(function(component){return 0<component.length}).map(ilib.bind(this,function(component){var name=component.replace(/.*{/,""),component={component:name,label:rb.getStringJS(this.info.fieldNames[name])},field=fields.filter(function(f){return f.name===name});return field&&field[0]&&field[0].pattern&&"string"==typeof field[0].pattern&&(component.constraint=field[0].pattern),"country"===name?component.constraint=invertAndFilter(localeAddress.ctrynames):"region"===name&&this.regions[loc.getRegion()]&&(component.constraint=this.regions[loc.getRegion()]),component}))})),callback&&"function"==typeof callback&&callback(info)})})})})})}),info},module.exports=AddressFmt;
|
package/lib/AlphabeticIndex.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// !data nfc nfkd
|
|
2
|
-
var ilib=require("../index.js"),Utils=require("./Utils.js"),Locale=require("./Locale.js"),CType=require("./CType.js"),IString=require("./IString.js"),isIdeo=require("./isIdeo.js"),isAscii=require("./isAscii.js"),isDigit=require("./isDigit.js"),Collator=require("./Collator.js"),NormString=require("./NormString.js"),AlphabeticIndex=function(options){this.sync=!0,this.loadParams={},this.caseSensitive=!1,this.accentSensitive=!1,this.overflowLabel="#",this.underflowLabel="*",this.style="standard",this.index=[],options&&(options.locale&&(this.locale="string"==typeof options.locale?new Locale(options.locale):options.locale),void 0!==options.style&&(this.style=options.style),void 0!==options.overflowLabel&&(this.overflowLabel=options.overflowLabel),void 0!==options.underflowLabel&&(this.underflowLabel=options.underflowLabel),void 0!==options.sync&&(this.sync=!!options.sync),options.loadParams&&(this.loadParams=options.loadParams)
|
|
2
|
+
var ilib=require("../index.js"),Utils=require("./Utils.js"),Locale=require("./Locale.js"),CType=require("./CType.js"),IString=require("./IString.js"),isIdeo=require("./isIdeo.js"),isAscii=require("./isAscii.js"),isDigit=require("./isDigit.js"),Collator=require("./Collator.js"),NormString=require("./NormString.js"),AlphabeticIndex=function(options){this.sync=!0,this.loadParams={},this.caseSensitive=!1,this.accentSensitive=!1,this.overflowLabel="#",this.underflowLabel="*",this.style="standard",this.index=[],options&&(options.locale&&(this.locale="string"==typeof options.locale?new Locale(options.locale):options.locale),void 0!==options.style&&(this.style=options.style),void 0!==options.overflowLabel&&(this.overflowLabel=options.overflowLabel),void 0!==options.underflowLabel&&(this.underflowLabel=options.underflowLabel),void 0!==options.sync&&(this.sync=!!options.sync),options.loadParams)&&(this.loadParams=options.loadParams),this.locale=this.locale||new Locale(),isAscii._init(this.sync,this.loadParams,ilib.bind(this,function(){isIdeo._init(this.sync,this.loadParams,ilib.bind(this,function(){isDigit._init(this.sync,this.loadParams,ilib.bind(this,function(){NormString.init({sync:this.sync,loadParam:this.loadParams,onLoad:ilib.bind(this,function(){new Collator({locale:this.locale,useNative:!1,sensitivity:"primary",usage:"search",sync:this.sync,loadParam:this.loadParams,onLoad:ilib.bind(this,function(collation){this.collationObj=collation,this._init(),options&&"function"==typeof options.onLoad&&options.onLoad(this)})})})})}))}))}))};AlphabeticIndex.prototype._updateCollationMap=function(){this.mixedCollationMap=new Array(),Utils.loadData({object:"Collator",locale:this.locale,name:"collation.json",sync:!0,loadParams:this.loadParams,callback:ilib.bind(this,function(collations){for(var i=0;i<this.inherit.length;i++){var collationData={};"this"===this.inherit[i]?(collationData.style=this.style,collationData.flowBoundaries=this.flowBoundaries,collationData.indexUnits=this.indexUnits,collationData.map=this.collationMap):(collationData.style=this.inherit[i],collationData.flowBoundaries=collations[this.inherit[i]].flowBoundaries,collationData.indexUnits=collations[this.inherit[i]].indexUnits,collationData.map=collations[this.inherit[i]].map),this.mixedCollationMap.push(collationData)}})})},AlphabeticIndex.prototype._init=function(){this.flowBoundaries=new Array(),"standard"===this.style&&(this.style=this.collationObj.defaultRule),this.collationMap=this.collationObj.collation.map,this.flowBoundaries=this.collationObj.collation.flowBoundaries,this.indexUnits=this.collationObj.collation.indexUnits,this.inherit=this.collationObj.collation.inherit,void 0!==this.inherit&&this._updateCollationMap()},AlphabeticIndex.prototype._getKeyByValue=function(value,validMapNum){var i,label;if(!value||!ilib.isArray(value))return"";for(this.inherit&&-1<validMapNum&&(this.collationMap=this.mixedCollationMap[validMapNum].map,this.indexUnits=this.mixedCollationMap[validMapNum].indexUnits),i=0;i<this.indexUnits.length;i++)if(this.collationMap[this.indexUnits[i]][0]===value[0]){label=this.indexUnits[i];break}return label},AlphabeticIndex.prototype._getFirstChar=function(element){var firstChar;return element?(firstChar=(element=new NormString(element)).normalize("nfc").charIterator().next(),CType.withinRange(firstChar,"hangul")?element.normalize("nfkd").charIterator().next():firstChar):""},AlphabeticIndex.prototype._getLabelIndex=function(label){if(label){for(var indexNum,i=0;i<this.index.length;i++)if(this.index[i].label===label){indexNum=i;break}return indexNum}},AlphabeticIndex.prototype.getLocale=function(){return this.locale},AlphabeticIndex.prototype.addElement=function(element){if("string"==typeof element){var i,label=this.getBucket(element),newItem=!0,itemSet={};for(itemSet.label=label,itemSet.elements=[],i=0;i<this.index.length;i++)if(this.index[i].label===label){-1===this.index[i].elements.indexOf(element)&&this.index[i].elements.push(element),newItem=!1;break}return newItem&&(itemSet.elements.push(element),this.index.push(itemSet)),label}},AlphabeticIndex.prototype.addLabels=function(labels,start){var allBucketLabels=[];if(labels||ilib.isArray(labels)){if(allBucketLabels=this.getAllBucketLabels(),!start||start>allBucketLabels.length)allBucketLabels=allBucketLabels.concat(labels);else if("string"==typeof labels)allBucketLabels.splice(start,0,labels);else if("object"==typeof labels)for(var j=labels.length-1;0<=j;j--)allBucketLabels.splice(start,0,labels[j]);this.allBucketLabels=allBucketLabels}},AlphabeticIndex.prototype.clear=function(){for(var prop in this.index)this.index.hasOwnProperty(prop)&&(this.index[prop]="")},AlphabeticIndex.prototype.getAllBuckets=function(){for(var temp,itemIndex,underflowIndex=-1,overflowIndex=-1,mixedScriptEndIndex=-1,count=0,tempArr=[],tempIndex=[],tempBucket={},i=0;i<this.index.length;i++)tempArr.push(this.index[i].label);for(tempArr.sort(ilib.bind(this.collationObj,this.collationObj.compare)),i=0;i<tempArr.length;i++)(tempBucket={}).label=tempArr[i],itemIndex=this._getLabelIndex(tempArr[i]),this.index[itemIndex].elements.sort(ilib.bind(this.collationObj,this.collationObj.compare)),tempBucket.elements=this.index[itemIndex].elements,tempIndex[i]=tempBucket,tempBucket={};for(this.index=tempIndex,i=0;i<this.index.length;i++)this.inherit&&-1===this.mixedCollationMap[0].indexUnits.indexOf(this.index[i].label)&&(mixedScriptEndIndex=i,count++);for(this.inherit&&0<count&&(temp=this.index.splice(mixedScriptEndIndex-count+1,count),this.index=this.index.concat(temp)),i=0;i<this.index.length;i++)if(this.index[i].label===this.underflowLabel){underflowIndex=i;break}for(0<underflowIndex&&(temp=this.index.splice(underflowIndex,1)[0],this.index.unshift(temp)),i=0;i<this.index.length;i++)if(this.index[i].label===this.overflowLabel){overflowIndex=i;break}return-1<overflowIndex&&(temp=this.index.splice(overflowIndex,1)[0],this.index.push(temp)),this.index},AlphabeticIndex.prototype.getBucket=function(element){var label,firstChar,collationValue,charNum,firstBoundaryChar,firstCharNum,i,validMapNum=-1;if(element){if(firstChar=this._getFirstChar(element),this.inherit){for(i=0;i<this.mixedCollationMap.length;i++)if(this.mixedCollationMap[i].map[firstChar]){collationValue=this.mixedCollationMap[i].map[firstChar],validMapNum=i,this.flowBoundaries=this.mixedCollationMap[validMapNum].flowBoundaries,this.indexUnits=this.mixedCollationMap[validMapNum].indexUnits;break}}else collationValue=this.collationMap[firstChar];if(collationValue)"number"==typeof collationValue[0]?label=collationValue[0]<this.flowBoundaries[0]?this.underflowLabel:collationValue[0]>this.flowBoundaries[1]?this.overflowLabel:this._getKeyByValue(collationValue,validMapNum):"object"==typeof collationValue[0]&&(label=this._getKeyByValue(collationValue[0],validMapNum));else if(charNum=IString.toCodePoint(firstChar,0),this.inherit){for(i=0;i<this.inherit.length&&(firstBoundaryChar=this._getKeyByValue([this.mixedCollationMap[i].flowBoundaries[0]],i),charNum<(firstCharNum=IString.toCodePoint(firstBoundaryChar,0)));i++);label=i===this.inherit.length?this.underflowLabel:this.overflowLabel}else firstBoundaryChar=this._getKeyByValue([this.flowBoundaries[0]],0),element=this._getKeyByValue([this.flowBoundaries[1]],0),firstCharNum=IString.toCodePoint(firstBoundaryChar,0),IString.toCodePoint(element,0),label=charNum<firstCharNum?this.underflowLabel:this.overflowLabel;return label}},AlphabeticIndex.prototype.getIndexStyle=function(){return this.style},AlphabeticIndex.prototype.getBucketCount=function(){return Object.keys(this.index).length},AlphabeticIndex.prototype.getBucketLabels=function(){return this.getAllBuckets().map(function(bucket){return bucket.label})},AlphabeticIndex.prototype.getAllBucketLabels=function(){return this.allBucketLabels||(this.allBucketLabels=new Array(),this.allBucketLabels=[this.underflowLabel].concat(this.indexUnits,this.overflowLabel)),this.allBucketLabels},AlphabeticIndex.prototype.getCollator=function(){return this.collationObj},AlphabeticIndex.prototype.getOverflowLabel=function(){return this.overflowLabel},AlphabeticIndex.prototype.getElementCount=function(){for(var buckets=this.index,count=0,i=0;i<buckets.length;i++)count+=buckets[i].elements.length;return count},AlphabeticIndex.prototype.getUnderflowLabel=function(){return this.underflowLabel},AlphabeticIndex.prototype.setOverflowLabel=function(overflowLabel){this.overflowLabel=overflowLabel},AlphabeticIndex.prototype.setUnderflowLabel=function(underflowLabel){this.underflowLabel=underflowLabel},module.exports=AlphabeticIndex;
|
package/lib/Astro.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// !data astro
|
|
2
|
-
var ilib=require("../index.js"),Utils=require("./Utils.js"),SearchUtils=require("./SearchUtils.js"),GregorianDate=require("./GregorianDate.js"),RataDie=require("./RataDie.js"),GregRataDie=require("./GregRataDie.js"),Astro={initAstro:function(sync,loadParams,callback){ilib.data.astro?callback&&"function"==typeof callback&&callback(ilib.data.astro):Utils.loadData({object:"Astro",name:"astro.json",locale:"-",nonLocale:!0,sync:sync,loadParams:loadParams,callback:ilib.bind(this,function(astroData){ilib.data.astro=astroData,callback&&"function"==typeof callback&&callback(astroData)})})},_dtr:function(d){return d*Math.PI/180},_rtd:function(r){return 180*r/Math.PI},_dcos:function(d){return Math.cos(Astro._dtr(d))},_dsin:function(d){return Math.sin(Astro._dtr(d))},_dtan:function(d){return Math.tan(Astro._dtr(d))},_fixangle:function(a){return a-360*Math.floor(a/360)},_fixangr:function(a){return a-2*Math.PI*Math.floor(a/(2*Math.PI))},_equinox:function(year,which){var
|
|
2
|
+
var ilib=require("../index.js"),Utils=require("./Utils.js"),SearchUtils=require("./SearchUtils.js"),GregorianDate=require("./GregorianDate.js"),RataDie=require("./RataDie.js"),GregRataDie=require("./GregRataDie.js"),Astro={initAstro:function(sync,loadParams,callback){ilib.data.astro?callback&&"function"==typeof callback&&callback(ilib.data.astro):Utils.loadData({object:"Astro",name:"astro.json",locale:"-",nonLocale:!0,sync:sync,loadParams:loadParams,callback:ilib.bind(this,function(astroData){ilib.data.astro=astroData,callback&&"function"==typeof callback&&callback(astroData)})})},_dtr:function(d){return d*Math.PI/180},_rtd:function(r){return 180*r/Math.PI},_dcos:function(d){return Math.cos(Astro._dtr(d))},_dsin:function(d){return Math.sin(Astro._dtr(d))},_dtan:function(d){return Math.tan(Astro._dtr(d))},_fixangle:function(a){return a-360*Math.floor(a/360)},_fixangr:function(a){return a-2*Math.PI*Math.floor(a/(2*Math.PI))},_equinox:function(year,which){for(var year=year<1e3?(JDE0tab=ilib.data.astro._JDE0tab1000,year/1e3):(JDE0tab=ilib.data.astro._JDE0tab2000,(year-2e3)/1e3),JDE0tab=JDE0tab[which][0]+JDE0tab[which][1]*year+JDE0tab[which][2]*year*year+JDE0tab[which][3]*year*year*year+JDE0tab[which][4]*year*year*year*year,T=(JDE0tab-2451545)/36525,which=35999.373*T-2.47,year=1+.0334*Astro._dcos(which)+7e-4*Astro._dcos(2*which),S=0,j=0,i=0;i<24;i++)S+=ilib.data.astro._EquinoxpTerms[j]*Astro._dcos(ilib.data.astro._EquinoxpTerms[j+1]+ilib.data.astro._EquinoxpTerms[j+2]*T),j+=3;return JDE0tab+1e-5*S/year},_deltat:function(year){var i,t;return 1620<=year&&year<=2014?(i=Math.floor(year-1620),i=ilib.data.astro._deltaTtab[i]+(ilib.data.astro._deltaTtab[i+1]-ilib.data.astro._deltaTtab[i])*(year-1620-i)):(t=(year-2e3)/100,year<948?i=2177+497*t+44.1*t*t:(i=102+102*t+25.3*t*t,2e3<year&&year<2100&&(i+=.37*(year-2100)))),i},_obliqeq:function(jd){var u,i,v=u=(jd-2451545)/3652500,eps=23.43929111111111;if(Math.abs(u)<1)for(i=0;i<10;i++)eps+=ilib.data.astro._oterms[i]/3600*v,v*=u;return eps},_sunpos:function(jd){var Omega,ret={},T=(jd-2451545)/36525,T2=T*T,T3=T*T2;return ret.meanLongitude=Astro._fixangle(280.46646+36000.76983*T+3032e-7*T2),ret.meanAnomaly=Astro._fixangle(357.52911+35999.05029*T-1537e-7*T2-48e-8*T3),ret.eccentricity=.016708634-42037e-9*T-1.267e-7*T2,ret.equationOfCenter=(1.914602-.004817*T-14e-6*T2)*Astro._dsin(ret.meanAnomaly)+(.019993-101e-6*T)*Astro._dsin(2*ret.meanAnomaly)+289e-6*Astro._dsin(3*ret.meanAnomaly),ret.sunLongitude=ret.meanLongitude+ret.equationOfCenter,ret.apparentLong=ret.sunLongitude+-.00569+-.00478*Astro._dsin(Omega=125.04-1934.136*T),jd=Astro._obliqeq(jd)+.00256*Astro._dcos(Omega),ret.inclination=Astro._fixangle(23.4392911-.013004167*T-1.6389e-7*T2+5.036e-7*T3),ret.apparentRightAscension=Astro._fixangle(Astro._rtd(Math.atan2(Astro._dcos(jd)*Astro._dsin(ret.apparentLong),Astro._dcos(ret.apparentLong)))),ret},_nutation:function(jd){var i,j,t2,to10,ang,jd=(jd-2451545)/36525,ta=[],dp=0,de=0,ret={},t3=jd*(t2=jd*jd);for(ta[0]=Astro._dtr(297.850363+445267.11148*jd-.0019142*t2+t3/189474),ta[1]=Astro._dtr(357.52772+35999.05034*jd-1603e-7*t2-t3/3e5),ta[2]=Astro._dtr(134.96298+477198.867398*jd+.0086972*t2+t3/56250),ta[3]=Astro._dtr(93.27191+483202.017538*jd-.0036825*t2+t3/327270),ta[4]=Astro._dtr(125.04452-1934.136261*jd+.0020708*t2+t3/45e4),i=0;i<5;i++)ta[i]=Astro._fixangr(ta[i]);for(to10=jd/10,i=0;i<63;i++){for(j=ang=0;j<5;j++)0!=ilib.data.astro._nutArgMult[5*i+j]&&(ang+=ilib.data.astro._nutArgMult[5*i+j]*ta[j]);dp+=(ilib.data.astro._nutArgCoeff[4*i+0]+ilib.data.astro._nutArgCoeff[4*i+1]*to10)*Math.sin(ang),de+=(ilib.data.astro._nutArgCoeff[4*i+2]+ilib.data.astro._nutArgCoeff[4*i+3]*to10)*Math.cos(ang)}return ret.deltaPsi=dp/36e6,ret.deltaEpsilon=de/36e6,ret},_equationOfTime:function(jd){var tau=(jd-2451545)/365250,tau=280.4664567+360007.6982779*tau+.03032028*tau*tau+tau*tau*tau/49931+-tau*tau*tau*tau/15300+-tau*tau*tau*tau*tau/2e6;tau=Astro._fixangle(tau);var alpha=Astro._sunpos(jd).apparentRightAscension,nut=Astro._nutation(jd),deltaPsi=nut.deltaPsi,jd=Astro._obliqeq(jd)+nut.deltaEpsilon;return 180<(nut=tau-.0057183-alpha+deltaPsi*Astro._dcos(jd))&&(nut-=360),nut=nut*4/1440},_poly:function(x,coefficients){for(var result=coefficients[0],xpow=x,i=1;i<coefficients.length;i++)result+=coefficients[i]*xpow,xpow*=x;return result},_universalFromLocal:function(local,zone){return local-zone/1440},_localFromUniversal:function(local,zone){return local+zone/1440},_aberration:function(c){return 974e-7*Astro._dcos(177.63+35999.01847999999*c)-.005575},_nutation2:function(c){var a=Astro._poly(c,ilib.data.astro._nutCoeffA),c=Astro._poly(c,ilib.data.astro._nutCoeffB);return-.004778*Astro._dsin(a)-3667e-7*Astro._dsin(c)},_ephemerisCorrection:function(jd){var theta,jd=GregorianDate._calcYear(jd-1721424.5);return 1988<=jd&&jd<=2019?(jd-1933)/86400:1800<=jd&&jd<=1987?(theta=(new GregRataDie({year:jd,month:7,day:1,hour:0,minute:0,second:0}).getRataDie()-693596)/36525,Astro._poly(theta,1900<=jd?ilib.data.astro._coeff19th:ilib.data.astro._coeff18th)):1620<=jd&&jd<=1799?(196.58333-4.0675*(jd-=1600)+.0219167*jd*jd)/86400:((theta=new GregRataDie({year:jd,month:1,day:1,hour:0,minute:0,second:0}).getRataDie()-660724+.5)*theta/41048480-15)/86400},_ephemerisFromUniversal:function(jd){return jd+Astro._ephemerisCorrection(jd)},_universalFromEphemeris:function(jd){return jd-Astro._ephemerisCorrection(jd)},_julianCenturies:function(jd){return(Astro._ephemerisFromUniversal(jd)-2451545)/36525},_solarLongitude:function(jd){for(var c=Astro._julianCenturies(jd),longitude=0,len=ilib.data.astro._solarLongCoeff.length,i=0;i<len;i++)longitude+=ilib.data.astro._solarLongCoeff[i]*Astro._dsin(ilib.data.astro._solarLongAddends[i]+ilib.data.astro._solarLongMultipliers[i]*c);return longitude=(longitude=longitude*5729577951308232e-21+(282.7771834+36000.76953744*c))+(Astro._aberration(c)+Astro._nutation2(c)),Astro._fixangle(longitude)},_lunarLongitude:function(jd){for(var jd=Astro._julianCenturies(jd),meanMoon=Astro._fixangle(Astro._poly(jd,ilib.data.astro._meanMoonCoeff)),elongation=Astro._fixangle(Astro._poly(jd,ilib.data.astro._elongationCoeff)),solarAnomaly=Astro._fixangle(Astro._poly(jd,ilib.data.astro._solarAnomalyCoeff)),lunarAnomaly=Astro._fixangle(Astro._poly(jd,ilib.data.astro._lunarAnomalyCoeff)),moonNode=Astro._fixangle(Astro._poly(jd,ilib.data.astro._moonFromNodeCoeff)),e=Astro._poly(jd,ilib.data.astro._eCoeff),sum=0,i=0;i<ilib.data.astro._lunarElongationLongCoeff.length;i++){var x=ilib.data.astro._solarAnomalyLongCoeff[i];sum+=ilib.data.astro._sineCoeff[i]*Math.pow(e,Math.abs(x))*Astro._dsin(ilib.data.astro._lunarElongationLongCoeff[i]*elongation+x*solarAnomaly+ilib.data.astro._lunarAnomalyLongCoeff[i]*lunarAnomaly+ilib.data.astro._moonFromNodeLongCoeff[i]*moonNode)}var longitude=sum/1e6,venus=.003958*Astro._dsin(119.75+131.849*jd),jupiter=318e-6*Astro._dsin(53.09+479264.29*jd),flatEarth=.001962*Astro._dsin(meanMoon-moonNode);return Astro._fixangle(meanMoon+longitude+venus+jupiter+flatEarth+Astro._nutation2(jd))},_newMoonTime:function(n){for(var k=n-24724,n=k/1236.85,approx=Astro._poly(n,ilib.data.astro._nmApproxCoeff),capE=Astro._poly(n,ilib.data.astro._nmCapECoeff),solarAnomaly=Astro._poly(n,ilib.data.astro._nmSolarAnomalyCoeff),lunarAnomaly=Astro._poly(n,ilib.data.astro._nmLunarAnomalyCoeff),moonArgument=Astro._poly(n,ilib.data.astro._nmMoonArgumentCoeff),capOmega=Astro._poly(n,ilib.data.astro._nmCapOmegaCoeff),correction=-17e-5*Astro._dsin(capOmega),i=0;i<ilib.data.astro._nmSineCoeff.length;i++)correction+=ilib.data.astro._nmSineCoeff[i]*Math.pow(capE,ilib.data.astro._nmEFactor[i])*Astro._dsin(ilib.data.astro._nmSolarCoeff[i]*solarAnomaly+ilib.data.astro._nmLunarCoeff[i]*lunarAnomaly+ilib.data.astro._nmMoonCoeff[i]*moonArgument);var additional=0;for(i=0;i<ilib.data.astro._nmAddConst.length;i++)additional+=ilib.data.astro._nmAddFactor[i]*Astro._dsin(ilib.data.astro._nmAddConst[i]+ilib.data.astro._nmAddCoeff[i]*k);capOmega=325e-6*Astro._dsin(Astro._poly(n,ilib.data.astro._nmExtra));return Astro._universalFromEphemeris(approx+correction+capOmega+additional+RataDie.gregorianEpoch)},_lunarSolarAngle:function(jd){var lunar=Astro._lunarLongitude(jd),jd=Astro._solarLongitude(jd);return Astro._fixangle(lunar-jd)},_newMoonBefore:function(jd){for(var last,phase=Astro._lunarSolarAngle(jd),guess=Math.round((jd-11.450086114414322-RataDie.gregorianEpoch)/29.530588853-phase/360)-1,current=last=Astro._newMoonTime(guess);current<jd;)last=current,current=Astro._newMoonTime(++guess);return last},_newMoonAtOrAfter:function(jd){for(var current,phase=Astro._lunarSolarAngle(jd),guess=Math.round((jd-11.450086114414322-RataDie.gregorianEpoch)/29.530588853-phase/360);(current=Astro._newMoonTime(guess))<jd;)guess++;return current},_nextSolarLongitude:function(jd,longitude){var tau=jd+365.242189/360*Astro._fixangle(longitude-Astro._solarLongitude(jd)),jd=Math.max(jd,tau-5);return SearchUtils.bisectionSearch(0,jd,tau+5,1e-6,function(l){return 180-Astro._fixangle(Astro._solarLongitude(l)-longitude)})},_floorToJD:function(jd){return Math.floor(jd-.5)+.5},_ceilToJD:function(jd){return Math.ceil(jd+.5)-.5}};module.exports=Astro;
|
package/lib/AsyncNodeLoader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports=function(ilib){
|
|
1
|
+
module.exports=function(ilib){function AsyncNodeLoader(ilib){this.parent.call(this,ilib),this.root=process.cwd(),this.base="undefined"!=typeof module&&module.filename?path.join(path.dirname(module.filename),".."):this.root,this._exists(this.root,"resources"),this._exists(path.join(this.root,"locale"),"localeinfo.json"),this._exists(path.join(this.base,"locale"),"localeinfo.json"),this._exists("/usr/share/javascript/ilib/locale","localeinfo.json")}var path=require("./Path.js"),fs=require("fs"),Loader=(require("util"),require("./Loader.js"));return(AsyncNodeLoader.prototype=new Loader).parent=Loader,(AsyncNodeLoader.prototype.constructor=AsyncNodeLoader).prototype.name="AsyncNodeLoader",AsyncNodeLoader.prototype._loadFile=function(pathname,sync,cb){try{fs.readFile(pathname,"utf-8",function(err,text){"function"==typeof cb&&cb(err&&-2!==err.errno?void 0:text)})}catch(e){"function"==typeof cb&&cb()}},AsyncNodeLoader.prototype._exists=function(dir,file){file=path.normalize(path.join(dir,file));fs.existsSync(file)&&this.includePath.push(dir)},new AsyncNodeLoader(ilib)};
|
package/lib/CType.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// !data ctype
|
|
2
|
-
var ilib=require("../index.js"),SearchUtils=require("./SearchUtils.js"),Utils=require("./Utils.js"),IString=require("./IString.js"),CType={_inRange:function(num,rangeName,obj){var
|
|
2
|
+
var ilib=require("../index.js"),SearchUtils=require("./SearchUtils.js"),Utils=require("./Utils.js"),IString=require("./IString.js"),CType={_inRange:function(num,rangeName,obj){var result;return!(num<0||!rangeName||!obj)&&!!(obj=obj[rangeName])&&(result=SearchUtils.bsearch(num,obj,rangeName=function(singlerange,target){return 1===singlerange.length||target<singlerange[0]?singlerange[0]-target:target>singlerange[1]?singlerange[1]-target:0}))<obj.length&&0===rangeName(obj[result],num)},withinRange:function(ch,rangeName){if(!rangeName)return!1;var num;switch(typeof ch){case"number":num=ch;break;case"string":num=IString.toCodePoint(ch,0);break;case"undefined":return!1;default:num=ch._toCodePoint(0)}return CType._inRange(num,rangeName.toLowerCase(),ilib.data.ctype)},_init:function(sync,loadParams,onLoad){CType._load("ctype",sync,loadParams,onLoad)},_load:function(name,sync,loadParams,onLoad){ilib.data[name]?onLoad&&"function"==typeof onLoad&&onLoad(ilib.data[name]):Utils.loadData({object:"CType",name:name?name+".json":"CType.json",locale:"-",nonlocale:!0,sync:sync,loadParams:loadParams,callback:ilib.bind(this,function(ct){ilib.data[name]=ct,onLoad&&"function"==typeof onLoad&&onLoad(ilib.data[name])})})}};module.exports=CType;
|
package/lib/CalendarFactory.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var ilib=require("../index.js"),Locale=require("./Locale.js"),LocaleInfo=require("./LocaleInfo.js"),Calendar=require("./Calendar.js"),CalendarFactory=function(options){var locale,type,instance,sync=!0;return options&&(options.locale&&(locale="string"==typeof options.locale?new Locale(options.locale):options.locale),type=options.type||options.calendar,"boolean"==typeof options.sync&&(sync=options.sync)
|
|
1
|
+
var ilib=require("../index.js"),Locale=require("./Locale.js"),LocaleInfo=require("./LocaleInfo.js"),Calendar=require("./Calendar.js"),CalendarFactory=function(options){var locale,type,instance,sync=!0;return options&&(options.locale&&(locale="string"==typeof options.locale?new Locale(options.locale):options.locale),type=options.type||options.calendar,"boolean"==typeof options.sync)&&(sync=options.sync),locale=locale||new Locale(),type?instance=CalendarFactory._init(type,options):new LocaleInfo(locale,{sync:sync,loadParams:options&&options.loadParams,onLoad:function(info){type=info.getCalendar(),instance=CalendarFactory._init(type,options)}}),instance};function circumventWebPack(x){return"./"+x+"Cal.js"}CalendarFactory._dynMap={coptic:"Coptic",ethiopic:"Ethiopic",gregorian:"Gregorian",han:"Han",hebrew:"Hebrew",islamic:"Islamic",julian:"Julian",persian:"Persian","persian-algo":"PersianAlgo",thaisolar:"ThaiSolar"},CalendarFactory._dynLoadCalendar=function(name,fnc){var entry;return Calendar._constructors[name]||(entry=CalendarFactory._dynMap[name])&&(
|
|
2
2
|
// eslint-disable-next-line
|
|
3
|
-
Calendar._constructors[name]=require(fnc(entry)))
|
|
3
|
+
Calendar._constructors[name]=require(fnc(entry))),Calendar._constructors[name]},CalendarFactory._init=function(type,options){return ilib.isDynCode()&&CalendarFactory._dynLoadCalendar(type,circumventWebPack),(type=Calendar._constructors[type])||"function"!=typeof options.onLoad||options.onLoad(void 0),type&&new type(options)},CalendarFactory.getCalendars=function(){var c,arr=[];if(ilib.isDynCode())for(c in CalendarFactory._dynMap)CalendarFactory._dynLoadCalendar(c,circumventWebPack);for(c in Calendar._constructors)c&&Calendar._constructors[c]&&arr.push(c);return arr},module.exports=CalendarFactory;
|
package/lib/CaseMapper.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var ilib=require("../index.js"),Locale=require("./Locale.js"),IString=require("./IString.js"),CaseMapper=function(options){switch(this.up=!0,this.locale=new Locale(),options&&(void 0!==options.locale&&(this.locale="string"==typeof options.locale?new Locale(options.locale):options.locale),this.up=!options.direction||"toupper"===options.direction),this.mapData=this.up?{"ß":"SS","ΐ":"Ι","ά":"Α","έ":"Ε","ή":"Η","ί":"Ι","ΰ":"Υ","ϊ":"Ι","ϋ":"Υ","ό":"Ο","ύ":"Υ","ώ":"Ω","Ӏ":"Ӏ","ӏ":"Ӏ"}:{"Ӏ":"Ӏ"},this.locale.getLanguage()){case"az":case"tr":case"crh":case"kk":case"krc":case"tt":this._setUpMap("iı","İI")}"ie"!==ilib._getBrowser()&&"Edge"!==ilib._getBrowser()||(this.up&&(this.mapData["ς"]="Σ"),this._setUpMap("ⲁⲃⲅⲇⲉⲋⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⳁⳉⳋ","ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⳀⳈⳊ"),this._setUpMap("ⴀⴁⴂⴃⴄⴅⴆⴇⴈⴉⴊⴋⴌⴍⴎⴏⴐⴑⴒⴓⴔⴕⴖⴗⴘⴙⴚⴛⴜⴝⴞⴟⴠⴡⴢⴣⴤⴥ","ႠႡႢႣႤႥႦႧႨႩႪႫႬႭႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅ"))};CaseMapper.prototype={_charMapper:function(string){if(!string)return string;for(var c,ret="",it=("string"==typeof string?new IString(string):string.toString()).charIterator();it.hasNext();)
|
|
1
|
+
var ilib=require("../index.js"),Locale=require("./Locale.js"),IString=require("./IString.js"),CaseMapper=function(options){switch(this.up=!0,this.locale=new Locale(),options&&(void 0!==options.locale&&(this.locale="string"==typeof options.locale?new Locale(options.locale):options.locale),this.up=!options.direction||"toupper"===options.direction),this.mapData=this.up?{"ß":"SS","ΐ":"Ι","ά":"Α","έ":"Ε","ή":"Η","ί":"Ι","ΰ":"Υ","ϊ":"Ι","ϋ":"Υ","ό":"Ο","ύ":"Υ","ώ":"Ω","Ӏ":"Ӏ","ӏ":"Ӏ"}:{"Ӏ":"Ӏ"},this.locale.getLanguage()){case"az":case"tr":case"crh":case"kk":case"krc":case"tt":this._setUpMap("iı","İI")}"ie"!==ilib._getBrowser()&&"Edge"!==ilib._getBrowser()||(this.up&&(this.mapData["ς"]="Σ"),this._setUpMap("ⲁⲃⲅⲇⲉⲋⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⳁⳉⳋ","ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⳀⳈⳊ"),this._setUpMap("ⴀⴁⴂⴃⴄⴅⴆⴇⴈⴉⴊⴋⴌⴍⴎⴏⴐⴑⴒⴓⴔⴕⴖⴗⴘⴙⴚⴛⴜⴝⴞⴟⴠⴡⴢⴣⴤⴥ","ႠႡႢႣႤႥႦႧႨႩႪႫႬႭႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅ"))};CaseMapper.prototype={_charMapper:function(string){if(!string)return string;for(var c,code,ret="",it=("string"==typeof string?new IString(string):string.toString()).charIterator();it.hasNext();)c=it.next(),this.up||"Σ"!==c?this.mapData[c]?ret+=this.mapData[c]:ret+=this.up?c.toUpperCase():c.toLowerCase():it.hasNext()?ret=(ret+=(code=(c=it.next()).charCodeAt(0))<904&&902!==code||974<code?"ς":"σ")+c.toLowerCase():ret+="ς";return ret},_setUpMap:function(lower,upper){for(var from,to=this.up?(from=lower,upper):(from=upper,lower),i=0;i<upper.length;i++)this.mapData[from[i]]=to[i]},getLocale:function(){return this.locale},map:function(string){return this._charMapper(string)}},module.exports=CaseMapper;
|
package/lib/Charmap.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// !data charmaps charset/US-ASCII charset/ISO-10646-UCS-2 charset/ISO-8859-1 charset/ISO-8859-15 charmaps/ISO-8859-15 charmaps/ISO-8859-1 charset/ISO-8859-1
|
|
2
|
-
var ilib=require("../index.js"),JSUtils=require("./JSUtils.js"),IString=require("./IString.js"),Charmap=function(options){
|
|
2
|
+
var ilib=require("../index.js"),JSUtils=require("./JSUtils.js"),IString=require("./IString.js"),Charmap=function(options){var escapes;options&&options.noinstance||(this.missing="placeholder",this.placeholder="?",this.escapeStyle="js",this.expansionFactor=1,options&&(void 0!==options.placeholder&&(this.placeholder=options.placeholder),escapes={html:"html",js:"js","c#":"js",c:"c","c++":"c",java:"java",ruby:"java",perl:"perl"},void 0!==options.escapeStyle&&void 0!==escapes[options.escapeStyle]&&(this.escapeStyle=escapes[options.escapeStyle]),void 0===options.missing||"skip"!==options.missing&&"placeholder"!==options.missing&&"escape"!==options.missing||(this.missing=options.missing)))};Charmap._algorithms={},Charmap.prototype={getName:function(){return this.charset.getName()},writeNative:function(array,start,value){if(ilib.isArray(value)){for(var i=0;i<value.length;i++)array[start+i]=value[i];return value.length}return array[start]=value,1},writeNativeString:function(array,start,string){for(var i=0;i<string.length;i++)array[start+i]=string.charCodeAt(i);return string.length},_calcExpansionFactor:function(){var factor=1,factor=Math.max(factor,this.charset.getMaxCharWidth());switch(this.missing){case"placeholder":this.placeholder&&(factor=Math.max(factor,this.placeholder.length));break;case"escape":switch(this.escapeStyle){case"html":factor=Math.max(factor,8);break;case"c":factor=Math.max(factor,6);break;case"perl":factor=Math.max(factor,10);break;default:factor=Math.max(factor,6)}}this.expansionFactor=factor},dealWithMissingChar:function(c){var seq="";switch(this.missing){case"skip":break;case"escape":var num="string"==typeof c?c.charCodeAt(0):c,bigc=JSUtils.pad(num.toString(16),4).toUpperCase();switch(this.escapeStyle){case"html":seq="&#x"+bigc+";";break;case"c":seq="\\x"+bigc;break;case"java":seq="\\\\u"+bigc;break;case"perl":seq="\\N{U+"+bigc+"}";break;default:seq="\\u"+bigc}break;default:seq=this.placeholder}return seq},mapToNative:function(string){if(!string)return new Uint8Array(0);if(this.algorithm)return this.algorithm.mapToNative(string);for(var c,string=string instanceof IString?string:new IString(string),i=0,it=string.iterator(),ret=new Uint8Array(string.length*this.expansionFactor);it.hasNext()&&i<ret.length;)(c=it.next())<127?ret[i++]=c:i+=this.writeNativeString(ret,i,this.dealWithMissingChar(c));return ret},mapToUnicode:function(bytes){for(var c,ret="",i=0;i<bytes.length;)ret+=(c=bytes[i])<128?String.fromCharCode(c):this.dealWithMissingChar(bytes[i++]);return ret}},module.exports=Charmap;
|
package/lib/CharmapFactory.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var ilib=require("../index.js"),JSUtils=require("./JSUtils.js"),Charset=require("./Charset.js"),Charmap=require("./Charmap.js");function circumventWebpackCharmap(x){return"./"+x+".js"}var CharmapFactory=function(options){var instance,charsetName=options&&options.name||"ISO-8859-15",sync=!0;return options?"boolean"==typeof options.sync&&(sync=options.sync):options={sync:!0},new Charset({name:charsetName,sync:sync,loadParams:options.loadParams,onLoad:function(charset){var
|
|
1
|
+
var ilib=require("../index.js"),JSUtils=require("./JSUtils.js"),Charset=require("./Charset.js"),Charmap=require("./Charmap.js");function circumventWebpackCharmap(x){return"./"+x+".js"}var CharmapFactory=function(options){var instance,charsetName=options&&options.name||"ISO-8859-15",sync=!0;return options?"boolean"==typeof options.sync&&(sync=options.sync):options={sync:!0},new Charset({name:charsetName,sync:sync,loadParams:options.loadParams,onLoad:function(charset){var
|
|
2
2
|
// eslint-disable-next-line
|
|
3
|
-
|
|
3
|
+
entry,name=charset.getName();!Charmap._algorithms[name]&&ilib.isDynCode()&&(entry=CharmapFactory._dynMap[name]||"CharmapTable",entry=Charmap._algorithms[name]=require(circumventWebpackCharmap(entry))),entry=entry||Charmap._algorithms[name]||Charmap._algorithms.CharmapTable,instance=entry&&new entry(JSUtils.merge(options||{},{charset:charset}))}}),instance};CharmapFactory._dynMap={"UTF-8":"UTF8","UTF-16":"UTF16LE","UTF-16LE":"UTF16LE","UTF-16BE":"UTF16BE","US-ASCII":"Charmap"},module.exports=CharmapFactory;
|
package/lib/CharmapTable.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// !data charmaps/ISO-8859-15 charset/ISO-8859-15
|
|
2
|
-
var ilib=require("../index.js"),Utils=require("./Utils.js"),Charset=require("./Charset.js"),Charmap=require("./Charmap.js"),IString=require("./IString.js"),CharmapTable=function(options){this.parent.call(this,options),this.charsetName="ISO-8859-15",options?"object"==typeof options.charset?(this.charset=options.charset,this.charsetName=this.charset.getName()):void 0!==options.name&&(this.charsetName=options.name):options={sync:!0},this.charset?this._init(options):new Charset({name:this.charsetName,sync:!0,loadParams:options.loadParams,onLoad:ilib.bind(this,function(cs){this.charset=cs,this._init(options)})})};CharmapTable.prototype=new Charmap({noinstance:!0}),CharmapTable.prototype.parent=Charmap,(CharmapTable.prototype.constructor=CharmapTable).prototype._init=function(options){this._calcExpansionFactor(),Utils.loadData({object:"Charmap",locale:"-",nonlocale:!0,name:"charmaps/"+this.charset.getName()+".json",sync:options.sync,loadParams:options.loadParams,callback:ilib.bind(this,function(mapping){var ret=this;if(!mapping){if(options.sync)throw"No mapping found for "+this.charset.getName();ret=void 0}this.map=mapping,"function"==typeof options.onLoad&&options.onLoad(ret)})})},CharmapTable.prototype._trieWalk=function(trie,array,start){for(var
|
|
2
|
+
var ilib=require("../index.js"),Utils=require("./Utils.js"),Charset=require("./Charset.js"),Charmap=require("./Charmap.js"),IString=require("./IString.js"),CharmapTable=function(options){this.parent.call(this,options),this.charsetName="ISO-8859-15",options?"object"==typeof options.charset?(this.charset=options.charset,this.charsetName=this.charset.getName()):void 0!==options.name&&(this.charsetName=options.name):options={sync:!0},this.charset?this._init(options):new Charset({name:this.charsetName,sync:!0,loadParams:options.loadParams,onLoad:ilib.bind(this,function(cs){this.charset=cs,this._init(options)})})};CharmapTable.prototype=new Charmap({noinstance:!0}),CharmapTable.prototype.parent=Charmap,(CharmapTable.prototype.constructor=CharmapTable).prototype._init=function(options){this._calcExpansionFactor(),Utils.loadData({object:"Charmap",locale:"-",nonlocale:!0,name:"charmaps/"+this.charset.getName()+".json",sync:options.sync,loadParams:options.loadParams,callback:ilib.bind(this,function(mapping){var ret=this;if(!mapping){if(options.sync)throw"No mapping found for "+this.charset.getName();ret=void 0}this.map=mapping,"function"==typeof options.onLoad&&options.onLoad(ret)})})},CharmapTable.prototype._trieWalk=function(trie,array,start){for(var lastLeaf=void 0,i=start,trienode=trie;i<array.length;){if(void 0!==trienode.__leaf&&(lastLeaf={consumed:i-start+1,value:trienode.__leaf}),0===array[i])return{consumed:1,value:0};if(void 0===trienode[array[i]])return lastLeaf;if(function isValue(node){return"string"==typeof node||"number"==typeof node||"object"==typeof node&&ilib.isArray(node)}(trienode[array[i]]))return{consumed:i-start+1,value:trienode[array[i]]};trienode=trienode[array[i++]]}},CharmapTable.prototype.mapToNative=function(string){if(!string)return new Uint8Array(0);for(var str=string instanceof IString?string:new IString(string),ret=new Uint8Array(str.length*this.expansionFactor),i=0,j=0;i<string.length;){var result=this._trieWalk(this.map.from,string,i);result?result.value?(i+=result.consumed,j+=this.writeNative(ret,j,result.value)):(i=string.length,this.writeNative(ret,j,[result.value])):j+=this.writeNativeString(ret,j,this.dealWithMissingChar(string[i++]))}return ret.subarray(0,j)},CharmapTable.prototype.mapToUnicode=function(bytes){for(var ret="",i=0;i<bytes.length;){var result=this._trieWalk(this.map.to,bytes,i);if(result)if(result.value){if(i+=result.consumed,"string"==typeof result.value)ret+=result.value;else if(ilib.isArray(result.value))for(var j=0;j<result.value.length;j++)ret+=result.value[j]}else i=bytes.length;else ret+=this.dealWithMissingChar(bytes[i++])}return ret},Charmap._algorithms.CharmapTable=CharmapTable,module.exports=CharmapTable;
|
package/lib/Charset.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// !data charset charsetaliases charset/ISO-8859-1 charset/ISO-8859-15 charset/UTF-8
|
|
2
|
-
var ilib=require("../index.js"),Utils=require("./Utils.js"),Charset=function(options){var sync=!0,loadParams=void 0;this.originalName="UTF-8",options&&(void 0!==options.name&&(this.originalName=options.name),void 0!==options.sync&&(sync=!!options.sync),void 0!==options.loadParams&&(loadParams=options.loadParams)
|
|
2
|
+
var ilib=require("../index.js"),Utils=require("./Utils.js"),Charset=function(options){var sync=!0,loadParams=void 0;this.originalName="UTF-8",options&&(void 0!==options.name&&(this.originalName=options.name),void 0!==options.sync&&(sync=!!options.sync),void 0!==options.loadParams)&&(loadParams=options.loadParams),this.info={description:"default",min:1,max:1,bigendian:!0,scripts:["Latn"],locales:["*"]},Utils.loadData({object:"Charset",locale:"-",nonlocale:!0,name:"charsetaliases.json",sync:sync,loadParams:loadParams,callback:ilib.bind(this,function(info){var n;info&&(n=this.originalName.replace(/[-_,:\+\.\(\)]/g,"").toUpperCase(),this.name=info[n]),this.name||(this.name=this.originalName),Utils.loadData({object:"Charset",locale:"-",nonlocale:!0,name:"charset/"+this.name+".json",sync:sync,loadParams:loadParams,callback:ilib.bind(this,function(info){info&&ilib.extend(this.info,info),options&&"function"==typeof options.onLoad&&options.onLoad(this)})})})})};Charset.prototype={getName:function(){return this.name},getOriginalName:function(){return this.originalName},getDescription:function(){return this.info.description||this.getName()},getMinCharWidth:function(){return this.info.min},getMaxCharWidth:function(){return this.info.max},isMultibyte:function(){return this.getMaxCharWidth()>this.getMinCharWidth()},isBigEndian:function(){return this.info.bigendian},getScripts:function(){return this.info.scripts}},module.exports=Charset;
|
package/lib/CodePointSource.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var isPunct=require("./isPunct.js"),NormString=require("./NormString.js"),CodePointSource=function(str,ignorePunctuation){this.chars=[];
|
|
1
|
+
var isPunct=require("./isPunct.js"),NormString=require("./NormString.js"),CodePointSource=function(str,ignorePunctuation){this.chars=[];str="string"==typeof str?new NormString(str):str;this.it=str.charIterator(),this.ignorePunctuation="boolean"==typeof ignorePunctuation&&ignorePunctuation};CodePointSource.prototype.peek=function(num){if(!(num<1)){if(this.chars.length<num&&this.it.hasNext())for(;this.chars.length<4&&this.it.hasNext();0){var c=this.it.next();(!c||this.ignorePunctuation)&&isPunct(c)||this.chars.push(c)}if(!(this.chars.length<num))return this.chars.slice(0,num).join("")}},CodePointSource.prototype.consume=function(num){0<num&&(this.peek(num),num<this.chars.length?this.chars=this.chars.slice(num):this.chars=[])},module.exports=CodePointSource;
|
package/lib/Collator.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// !data collation
|
|
2
|
-
var ilib=require("../index.js"),Utils=require("./Utils.js"),JSUtils=require("./JSUtils.js"),Locale=require("./Locale.js"),INumber=require("./INumber.js"),isPunct=require("./isPunct.js"),NormString=require("./NormString.js"),CodePointSource=require("./CodePointSource.js"),ElementIterator=require("./ElementIterator.js"),GlyphString=require("./GlyphString.js"),Collator=function(options){var sync=!0,loadParams=void 0,useNative=!0;if(this.locale=new Locale(ilib.getLocale()),this.caseFirst="upper",this.sensitivity="variant",this.level=4,this.usage="sort",this.reverse=!1,this.numeric=!1,this.style="default",this.ignorePunctuation=!1,options){if(options.locale&&(this.locale="string"==typeof options.locale?new Locale(options.locale):options.locale),options.sensitivity)switch(options.sensitivity){case"primary":case"base":this.sensitivity="base",this.level=1;break;case"secondary":case"accent":this.sensitivity="accent",this.level=2;break;case"tertiary":case"case":this.sensitivity="case",this.level=3;break;case"quaternary":case"variant":this.sensitivity="variant",this.level=4}void 0!==options.upperFirst&&(this.caseFirst=options.upperFirst?"upper":"lower"),void 0!==options.ignorePunctuation&&(this.ignorePunctuation=options.ignorePunctuation),void 0!==options.sync&&(sync=!!options.sync),loadParams=options.loadParams,void 0!==options.useNative&&(useNative=options.useNative),"sort"!==options.usage&&"search"!==options.usage||(this.usage=options.usage),"boolean"==typeof options.reverse&&(this.reverse=options.reverse),"boolean"==typeof options.numeric&&(this.numeric=options.numeric),"string"==typeof options.style&&(this.style=options.style)}else options={sync:!0};"sort"===this.usage&&(this.level=4),useNative&&"undefined"!=typeof Intl&&Intl?(this.collator=new Intl.Collator(this.locale.getSpec(),{sensitivity:this.sensitivity,caseFirst:this.caseFirst,ignorePunctuation:this.ignorePunctuation,numeric:this.numeric,usage:this.usage}),options&&"function"==typeof options.onLoad&&options.onLoad(this)):Utils.loadData({object:"Collator",locale:this.locale,name:"collation.json",replace:!0,sync:sync,loadParams:loadParams,callback:ilib.bind(this,function(collation){collation||
|
|
2
|
+
var ilib=require("../index.js"),Utils=require("./Utils.js"),JSUtils=require("./JSUtils.js"),Locale=require("./Locale.js"),INumber=require("./INumber.js"),isPunct=require("./isPunct.js"),NormString=require("./NormString.js"),CodePointSource=require("./CodePointSource.js"),ElementIterator=require("./ElementIterator.js"),GlyphString=require("./GlyphString.js"),Collator=function(options){var sync=!0,loadParams=void 0,useNative=!0;if(this.locale=new Locale(ilib.getLocale()),this.caseFirst="upper",this.sensitivity="variant",this.level=4,this.usage="sort",this.reverse=!1,this.numeric=!1,this.style="default",this.ignorePunctuation=!1,options){if(options.locale&&(this.locale="string"==typeof options.locale?new Locale(options.locale):options.locale),options.sensitivity)switch(options.sensitivity){case"primary":case"base":this.sensitivity="base",this.level=1;break;case"secondary":case"accent":this.sensitivity="accent",this.level=2;break;case"tertiary":case"case":this.sensitivity="case",this.level=3;break;case"quaternary":case"variant":this.sensitivity="variant",this.level=4}void 0!==options.upperFirst&&(this.caseFirst=options.upperFirst?"upper":"lower"),void 0!==options.ignorePunctuation&&(this.ignorePunctuation=options.ignorePunctuation),void 0!==options.sync&&(sync=!!options.sync),loadParams=options.loadParams,void 0!==options.useNative&&(useNative=options.useNative),"sort"!==options.usage&&"search"!==options.usage||(this.usage=options.usage),"boolean"==typeof options.reverse&&(this.reverse=options.reverse),"boolean"==typeof options.numeric&&(this.numeric=options.numeric),"string"==typeof options.style&&(this.style=options.style)}else options={sync:!0};"sort"===this.usage&&(this.level=4),useNative&&"undefined"!=typeof Intl&&Intl?(this.collator=new Intl.Collator(this.locale.getSpec(),{sensitivity:this.sensitivity,caseFirst:this.caseFirst,ignorePunctuation:this.ignorePunctuation,numeric:this.numeric,usage:this.usage}),options&&"function"==typeof options.onLoad&&options.onLoad(this)):Utils.loadData({object:"Collator",locale:this.locale,name:"collation.json",replace:!0,sync:sync,loadParams:loadParams,callback:ilib.bind(this,function(collation){collation=collation||ilib.data.collation,this._initCollation(collation),this.ignorePunctuation?isPunct._init(sync,loadParams,ilib.bind(this,function(){this._init(options)})):this._init(options)})})};Collator.prototype={_init:function(options){this.numeric?new INumber("1",{sync:options.sync,loadParams:options.loadParams,onLoad:function(n){"function"==typeof options.onLoad&&options.onLoad(this)}}):"function"==typeof options.onLoad&&options.onLoad(this)},_pack:function(arr,offset){var value=0;if(arr){"number"==typeof arr&&(arr=[arr]);for(var i=0;i<this.level;i++){var thisLevel=void 0!==arr[i]?arr[i]:0;0===i&&(thisLevel+=offset),0<i&&(value<<=this.collation.bits[i]),2===i&&"lower"===this.caseFirst?value|=1-thisLevel:value|=thisLevel}}return value},_packRule:function(rule,offset){if(ilib.isArray(rule[0])){for(var ret=[],i=0;i<rule.length;i++)ret.push(this._pack(rule[i],offset));return ret}return[this._pack(rule,offset)]},_addChars:function(str,offset){for(var it=new GlyphString(str).charIterator();it.hasNext();){if("'"===(c=it.next()))for(var c="",x="";it.hasNext()&&"'"!==x;)c+=x,x=it.next();this.lastMap++,this.map[c]=this._packRule([this.lastMap],offset)}},_addRules:function(rules,start){var p,r;for(r in rules.map)r&&(this.map[r]=this._packRule(rules.map[r],start),p=("number"==typeof rules.map[r][0]?rules.map[r]:rules.map[r][0])[0],this.lastMap=Math.max(p+start,this.lastMap));if(void 0!==rules.ranges)for(var i=0;i<rules.ranges.length;i++){var range=rules.ranges[i];if(this.lastMap=range.start,"string"==typeof range.chars)this._addChars(range.chars,start);else for(var k=0;k<range.chars.length;k++)this._addChars(range.chars[k],start)}},_initCollation:function(rules){for(var rule=this.style;"string"==typeof rule;)rule=rules[rule];if(!rule)for(rule="default";"string"==typeof rule;)rule=rules[rule];if(rule){if(this.collation=rule,this.map={},this.lastMap=-1,this.keysize=this.collation.keysize[this.level-1],this.defaultRule=rules.default,void 0!==this.collation.inherit)for(var col,i=0;i<this.collation.inherit.length;i++)"this"!==this.collation.inherit&&rules[rule="object"==typeof(col=this.collation.inherit[i])?col.name:col]&&this._addRules(rules[rule],col.start||this.lastMap+1);this._addRules(this.collation,this.lastMap+1)}else this.map={}},_basicCompare:function(left,right){var lelements,relements,diff,l=left instanceof NormString?left:new NormString(left),r=right instanceof NormString?right:new NormString(right);if(this.numeric){var lvalue=new INumber(left,{locale:this.locale}),rvalue=new INumber(right,{locale:this.locale});if(!isNaN(lvalue.valueOf())&&!isNaN(rvalue.valueOf())){if(diff=lvalue.valueOf()-rvalue.valueOf())return diff;l=new NormString(left.substring(lvalue.parsed.length)),r=new NormString(right.substring(rvalue.parsed.length))}}for(lelements=new ElementIterator(new CodePointSource(l,this.ignorePunctuation),this.map,this.keysize),relements=new ElementIterator(new CodePointSource(r,this.ignorePunctuation),this.map,this.keysize);lelements.hasNext()&&relements.hasNext();)if(diff=lelements.next()-relements.next())return diff;return lelements.hasNext()||relements.hasNext()?lelements.hasNext()?1:-1:0},compare:function(left,right){return this.collator?this.collator.compare(left,right):(left=this._basicCompare(left,right),this.reverse?-left:left)},getComparator:function(){return this.collator?this.collator.compare:ilib.bind(this,this.compare)},sortKey:function(str){if(!str)return"";if(this.collator)return str;if(this.numeric)return v=new INumber(str,{locale:this.locale}),v=isNaN(v.valueOf())?"":v.valueOf().toString(16),JSUtils.pad(v,16);for(var element,v="string"==typeof str?new NormString(str):str,ret="",lelements=new ElementIterator(new CodePointSource(v,this.ignorePunctuation),this.map,this.keysize);lelements.hasNext();)element=lelements.next(),this.reverse&&(element=(1<<this.keysize)-element),ret+=JSUtils.pad(element.toString(16),this.keysize/4);return ret}},Collator.getAvailableStyles=function(locale){return["standard"]},Collator.getAvailableScripts=function(){return["Latn"]},Collator.prototype.getDefaultCollatorStyle=function(){return this.defaultRule},module.exports=Collator;
|
package/lib/Country.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// !data ctryreverse
|
|
2
|
-
var ilib=require("../index.js"),Utils=require("./Utils.js"),Locale=require("./Locale.js"),LocaleInfo=require("./LocaleInfo.js"),ResBundle=require("./ResBundle.js"),Country=function(options){var locale,sync=!0,loadParams=void 0;options&&(options.locale&&(this.locale="string"==typeof options.locale?new Locale(options.locale):options.locale),void 0!==options.sync&&(sync=!!options.sync),options.loadParams&&(loadParams=options.loadParams)
|
|
2
|
+
var ilib=require("../index.js"),Utils=require("./Utils.js"),Locale=require("./Locale.js"),LocaleInfo=require("./LocaleInfo.js"),ResBundle=require("./ResBundle.js"),Country=function(options){var locale,sync=!0,loadParams=void 0;options&&(options.locale&&(this.locale="string"==typeof options.locale?new Locale(options.locale):options.locale),void 0!==options.sync&&(sync=!!options.sync),options.loadParams)&&(loadParams=options.loadParams),this.locale=this.locale||new Locale(),new LocaleInfo(this.locale,{sync:sync,loadParams:loadParams,onLoad:ilib.bind(this,function(li){this.locinfo=li,locale=void 0===this.locinfo.getRegionName()?"en-US":this.locale,this.codeToCountry?(this._calculateCountryToCode(),options&&"function"==typeof options.onLoad&&options.onLoad(this)):Utils.loadData({name:"ctryreverse.json",object:"Country",locale:locale,sync:sync,loadParams:loadParams,callback:ilib.bind(this,function(countries){this.codeToCountry=countries,this._calculateCountryToCode(),options&&"function"==typeof options.onLoad&&options.onLoad(this)})})})})};Country.getAvailableCode=function(){var countries=new ResBundle({name:"ctryreverse"}).getResObj();return countries&&Object.keys(countries)},Country.getAvailableCountry=function(){var code,ret=[],countries=new ResBundle({name:"ctryreverse"}).getResObj();for(code in countries)code&&countries[code]&&ret.push(countries[code]);return ret},Country.prototype={_calculateCountryToCode:function(){var code,temp=this.codeToCountry;for(code in this.countryToCode={},temp)code&&temp[code]&&(this.countryToCode[temp[code]]=code)},getCode:function(ctryname){if(this.countryToCode[ctryname])return this.countryToCode[ctryname];throw"Country "+ctryname+" is unknown"},getName:function(code){if(this.codeToCountry[code])return this.codeToCountry[code];throw"Country "+code+" is unknown"},getLocale:function(){return this.locale}},module.exports=Country;
|
package/lib/DateFactory.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var ilib=require("../index.js"),JSUtils=require("./JSUtils.js"),Locale=require("./Locale.js"),LocaleInfo=require("./LocaleInfo.js"),JulianDay=require("./JulianDay.js"),CalendarFactory=require("./CalendarFactory.js"),IDate=require("./IDate.js"),DateFactory=function(options){var locale,type,obj,sync=!0;return options&&(options.locale&&(locale="string"==typeof options.locale?new Locale(options.locale):options.locale),type=options.type||options.calendar,"boolean"==typeof options.sync&&(sync=options.sync)
|
|
1
|
+
var ilib=require("../index.js"),JSUtils=require("./JSUtils.js"),Locale=require("./Locale.js"),LocaleInfo=require("./LocaleInfo.js"),JulianDay=require("./JulianDay.js"),CalendarFactory=require("./CalendarFactory.js"),IDate=require("./IDate.js"),DateFactory=function(options){var locale,type,obj,sync=!0;return options&&(options.locale&&(locale="string"==typeof options.locale?new Locale(options.locale):options.locale),type=options.type||options.calendar,"boolean"==typeof options.sync)&&(sync=options.sync),locale=locale||new Locale(),type?obj=DateFactory._init(type,options):new LocaleInfo(locale,{sync:sync,loadParams:options&&options.loadParams,onLoad:function(info){type=info.getCalendar(),obj=DateFactory._init(type,options)}}),obj};function circumventWebPackDate(x){return"./"+x+"Date.js"}function circumventWebPackCal(x){return"./"+x+"Cal.js"}DateFactory._dynMap={coptic:"Coptic",ethiopic:"Ethiopic",gregorian:"Gregorian",han:"Han",hebrew:"Hebrew",islamic:"Islamic",julian:"Julian",persian:"Persian","persian-algo":"PersianAlgo",thaisolar:"ThaiSolar"},DateFactory._dynLoadDate=function(name,fnc){var entry;return IDate._constructors[name]||(entry=DateFactory._dynMap[name])&&(
|
|
2
2
|
// eslint-disable-next-line
|
|
3
|
-
IDate._constructors[name]=require(fnc(entry)))
|
|
3
|
+
IDate._constructors[name]=require(fnc(entry))),IDate._constructors[name]},DateFactory._init=function(type,options){return ilib.isDynCode()&&(DateFactory._dynLoadDate(type,circumventWebPackDate),CalendarFactory._dynLoadCalendar(type,circumventWebPackCal)),!(type=IDate._constructors[type])&&options&&"function"==typeof options.onLoad&&options.onLoad(void 0),type&&new type(options)},DateFactory._dateToIlib=function(inDate,timezone,locale){return null==inDate||inDate instanceof IDate?inDate:"number"==typeof inDate?DateFactory({unixtime:inDate,timezone:timezone,locale:locale}):("string"==typeof inDate&&(inDate=new Date(inDate)),JSUtils.isDate(inDate)?DateFactory({unixtime:inDate.getTime(),timezone:timezone,locale:locale}):inDate instanceof JulianDay?DateFactory({jd:inDate,timezone:timezone,locale:locale}):DateFactory("object"==typeof inDate?inDate:{unixtime:inDate.getTime(),timezone:timezone,locale:locale}))},DateFactory._ilibToDate=function(ilibDate,timezone,locale){return"object"==typeof ilibDate&&ilibDate instanceof IDate?new Date(ilibDate.getTimeExtended()):ilibDate},module.exports=DateFactory;
|
package/lib/DateFmt.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// !data dateformats sysres
|
|
2
|
-
var ilib=require("../index.js"),Utils=require("./Utils.js"),JSUtils=require("./JSUtils.js"),Locale=require("./Locale.js"),LocaleInfo=require("./LocaleInfo.js"),IDate=require("./IDate.js"),DateFactory=require("./DateFactory.js"),CalendarFactory=require("./CalendarFactory.js"),ResBundle=require("./ResBundle.js"),TimeZone=require("./TimeZone.js"),GregorianCal=require("./GregorianCal.js"),ISet=require("./ISet.js"),DateFmt=function(options){var arr,i,bad,c,comps,loadParams,sync=!0;if(this.locale=new Locale(),this.type="date",this.length="s",this.dateComponents="dmy",this.timeComponents="ahm",this.meridiems="default",this.useIntl=!1,(options=options||{sync:!0}).locale&&(this.locale="string"==typeof options.locale?new Locale(options.locale):options.locale),options.type&&("date"!==options.type&&"time"!==options.type&&"datetime"!==options.type||(this.type=options.type)),options.calendar&&(this.calName=options.calendar),options.length&&("short"!==options.length&&"medium"!==options.length&&"long"!==options.length&&"full"!==options.length||(this.length=options.length.charAt(0))),options.date){arr=options.date.split("");var dateComps=new ISet();for(bad=!1,i=0;i<arr.length;i++)if("e"===(c=arr[i].toLowerCase())&&(c="w"),"d"!==c&&"m"!==c&&"y"!==c&&"w"!==c&&"n"!==c){if("h"!==c&&"m"!==c&&"s"!==c&&"a"!==c&&"z"!==c&&"g"!==c){bad=!0;break}}else dateComps.add(c);bad||(comps=dateComps.asArray().sort(function(left,right){return left<right?-1:right<left?1:0}),this.dateComponents=comps.join(""))}if(options.time){arr=options.time.split("");var timeComps=new ISet();for(this.badTime=!1,i=0;i<arr.length;i++)if("h"!==(c=arr[i].toLowerCase())&&"m"!==c&&"s"!==c&&"a"!==c&&"z"!==c){if("d"!==c&&"m"!==c&&"y"!==c&&"w"!==c&&"e"!==c&&"n"!==c&&"g"!==c){this.badTime=!0;break}}else timeComps.add(c);this.badTime||(comps=timeComps.asArray().sort(function(left,right){return left<right?-1:right<left?1:0}),this.timeComponents=comps.join(""))}!options.clock||"12"!==options.clock&&"24"!==options.clock||(this.clock=options.clock),options.template&&(this.type="",this.length="",this.dateComponents="",this.timeComponents="",this.template=options.template),options.timezone&&(options.timezone instanceof TimeZone?(this.tz=options.timezone,this.timezone=this.tz.getId()):this.timezone=options.timezone),"boolean"==typeof options.useNative&&(this.useNative=options.useNative),void 0===options.meridiems||"chinese"!==options.meridiems&&"gregorian"!==options.meridiems&&"ethiopic"!==options.meridiems||(this.meridiems=options.meridiems),void 0!==options.sync&&(sync=!0===options.sync),void 0!==options.useIntl&&(this.useIntl=options.useIntl),loadParams=options.loadParams,new LocaleInfo(this.locale,{sync:sync,loadParams:loadParams,onLoad:ilib.bind(this,function(li){if(this.locinfo=li,this.calName=this.calName||this.locinfo.getCalendar()||"gregorian",this.useIntl&&"undefined"!=typeof Intl&&void 0!==Intl.DateTimeFormat&&void 0!==Intl.DateTimeFormat.supportedLocalesOf&&0<Intl.DateTimeFormat.supportedLocalesOf(this.locale.getSpec()).length&&"western"===this.locinfo.getDigitsStyle()&&!options.template&&"gregorian"===this.calName){var len=DateFmt.lenmap[this.length];if("date"===this.type&&("dmy"===this.dateComponents&&"full"!==len||"dmwy"===this.dateComponents&&"full"===len))this.IntlDateTimeObj=new Intl.DateTimeFormat(this.locale.getSpec(),{dateStyle:len});else if("time"===this.type&&"ahm"===this.timeComponents||"ahms"===this.timeComponents){this.IntlDateTimeObj=new Intl.DateTimeFormat(this.locale.getSpec(),{timeStyle:{ahm:"short",ahms:"medium"}[this.timeComponents]})}else"date"===this.type&&"m"===this.dateComponents&&"full"===len?this.IntlDateTimeObj=new Intl.DateTimeFormat(this.locale.getSpec(),{month:"long"}):"date"===this.type&&"w"===this.dateComponents&&"full"===len?this.IntlDateTimeObj=new Intl.DateTimeFormat(this.locale.getSpec(),{weekday:"long"}):this.useIntl=!1}this.useIntl?"function"==typeof options.onLoad&&options.onLoad(this):(!this.IntlDateTimeObj&&ilib.isDynCode()&&DateFactory._init(this.calName),CalendarFactory({type:this.calName,sync:sync,loadParams:loadParams,onLoad:ilib.bind(this,function(cal){this.cal=cal,this.cal||(this.cal=new GregorianCal),"default"===this.meridiems&&(this.meridiems=li.getMeridiemsStyle()),new ResBundle({locale:this.locale,name:"sysres",sync:sync,loadParams:loadParams,onLoad:ilib.bind(this,function(rb){if(this.sysres=rb,this.tz)this._init(options);else{var timezone=options.timezone;timezone||options.locale||(timezone="local"),new TimeZone({locale:this.locale,id:timezone,sync:sync,loadParams:loadParams,onLoad:ilib.bind(this,function(tz){this.tz=tz,this._init(options)})})}})})})}))})})};DateFmt.lenmap={s:"short",m:"medium",l:"long",f:"full"},DateFmt.defaultFmt={gregorian:{order:"{date} {time}",date:{dmwy:"EEE d/MM/yyyy",dmy:"d/MM/yyyy",dmw:"EEE d/MM",dm:"d/MM",my:"MM/yyyy",dw:"EEE d",d:"dd",m:"MM",y:"yyyy",n:"NN",w:"EEE"},time:{12:"h:mm:ssa",24:"H:mm:ss"},range:{c00:"{st} - {et}, {sd}/{sm}/{sy}",c01:"{sd}/{sm} {st} - {ed}/{em} {et}, {sy}",c02:"{sd}/{sm} {st} - {ed}/{em} {et}, {sy}",c03:"{sd}/{sm}/{sy} {st} - {ed}/{em}/{ey} {et}",c10:"{sd}-{ed}/{sm}/{sy}",c11:"{sd}/{sm} - {ed}/{em} {sy}",c12:"{sd}/{sm}/{sy} - {ed}/{em}/{ey}",c20:"{sm}/{sy} - {em}/{ey}",c30:"{sy} - {ey}"}},islamic:"gregorian",hebrew:"gregorian",julian:"gregorian",buddhist:"gregorian",persian:"gregorian","persian-algo":"gregorian",han:"gregorian"},DateFmt.monthNameLenMap={short:"N",medium:"NN",long:"MMM",full:"MMMM"},DateFmt.weekDayLenMap={short:"E",medium:"EE",long:"EEE",full:"EEEE"},DateFmt.getMeridiemsRange=function(options){options=options||{sync:!0};var args=JSUtils.merge({},options);return args.onLoad=function(fmt){"function"==typeof options.onLoad&&options.onLoad(fmt.getMeridiemsRange())},new DateFmt(args).getMeridiemsRange()},DateFmt.isIntlDateTimeAvailable=function(locale){return!(!locale||!ilib._global("Intl")||void 0===Intl.DateTimeFormat||void 0===Intl.DateTimeFormat.supportedLocalesOf)&&0<Intl.DateTimeFormat.supportedLocalesOf(locale).length},DateFmt.prototype={_init:function(options){void 0===options.sync&&(options.sync=!0),Utils.loadData({object:"DateFmt",locale:this.locale,name:"dateformats.json",sync:options.sync,loadParams:options.loadParams,callback:ilib.bind(this,function(formats){formats||(formats=ilib.data.dateformats||DateFmt.defaultFmt),this.info=formats;var ret=this;if(this.template)this._massageTemplate();else if(void 0===this.clock&&(this.clock=this.locinfo.getClock()),"boolean"!=typeof options.sync||options.sync)this._initTemplate(formats),this._massageTemplate();else try{this._initTemplate(formats),this._massageTemplate()}catch(e){ret=void 0}"function"==typeof options.onLoad&&options.onLoad(ret)})})},_initTemplate:function(formats){if(!formats[this.calName])throw"No formats available for calendar "+this.calName+" in locale "+this.locale.toString();var name=formats[this.calName];switch(this.formats="string"==typeof name?formats[name]:name,this.template="",this.type){case"datetime":this.template=this.formats&&this._getLengthFormat(this.formats.order,this.length)||"{date} {time}",this.template=this.template.replace("{date}",this._getFormat(this.formats.date,this.dateComponents,this.length)||""),this.template=this.template.replace("{time}",this._getFormat(this.formats.time[this.clock],this.timeComponents,this.length)||"");break;case"date":this.template=this._getFormat(this.formats.date,this.dateComponents,this.length);break;case"time":this.template=this._getFormat(this.formats.time[this.clock],this.timeComponents,this.length)}this.componentOrder=this._getFormat(this.formats.date,"dmy","l").replace(/[^dMy]/g,"").replace(/y+/,"y").replace(/d+/,"d").replace(/M+/,"m")},_massageTemplate:function(){var i,digits;if(this.clock&&this.template){var temp="";switch(this.clock){case"24":for(i=0;i<this.template.length;i++)if("'"==this.template.charAt(i)){for(temp+=this.template.charAt(i++);i<this.template.length&&"'"!==this.template.charAt(i);)temp+=this.template.charAt(i++);i<this.template.length&&(temp+=this.template.charAt(i))}else"K"==this.template.charAt(i)?temp+="k":"h"==this.template.charAt(i)?temp+="H":temp+=this.template.charAt(i);this.template=temp;break;case"12":for(i=0;i<this.template.length;i++)if("'"==this.template.charAt(i)){for(temp+=this.template.charAt(i++);i<this.template.length&&"'"!==this.template.charAt(i);)temp+=this.template.charAt(i++);i<this.template.length&&(temp+=this.template.charAt(i))}else"k"==this.template.charAt(i)?temp+="K":"H"==this.template.charAt(i)?temp+="h":temp+=this.template.charAt(i);this.template=temp}}this.templateArr=this._tokenize(this.template),"boolean"==typeof this.useNative?this.useNative&&(digits=this.locinfo.getNativeDigits())&&(this.digits=digits):"native"===this.locinfo.getDigitsStyle()&&(digits=this.locinfo.getNativeDigits())&&(this.useNative=!0,this.digits=digits)},_tokenize:function(template){var start,ch,letter,i=0,arr=[];if(template)for(;i<template.length;){if(start=i,"'"===(ch=template.charAt(i))){for(i++;i<template.length&&"'"!==template.charAt(i);)i++;i<template.length&&i++}else if("a"<=ch&&ch<="z"||"A"<=ch&&ch<="Z")for(letter=template.charAt(i);i<template.length&&ch===letter;)ch=template.charAt(++i);else for(;i<template.length&&"'"!==ch&&(ch<"a"||"z"<ch)&&(ch<"A"||"Z"<ch);)ch=template.charAt(++i);arr.push(template.substring(start,i))}return arr},_getFormatInternal:function getFormatInternal(obj,components,length){if(void 0!==components&&obj&&obj[components])return this._getLengthFormat(obj[components],length)},_standAlones:{m:"l",my:"mys",d:"a",w:"e",y:"r"},_getFormat:function getFormat(obj,components,length){if(components&&this._standAlones[components]){var tmp=this._getFormatInternal(obj,this._standAlones[components],length);if(tmp)return tmp}return this._getFormatInternal(obj,components,length)},_getLengthFormat:function getLengthFormat(obj,length){return"string"==typeof obj?obj:obj[length]?obj[length]:void 0},getLocale:function(){return this.locale},getTemplate:function(){return this.template},getDateComponentOrder:function(){return this.componentOrder},getType:function(){return this.type},getCalendar:function(){return this.cal.getType()||"gregorian"},getLength:function(){return DateFmt.lenmap[this.length]||""},getDateComponents:function(){return this.dateComponents||""},getTimeComponents:function(){return this.timeComponents||""},getTimeZone:function(){return this.tz},getClock:function(){return this.clock||this.locinfo.getClock()},getMeridiemsRange:function(){var result,_getSysString=function(key){return(this.sysres.getString(void 0,key+"-"+this.calName)||this.sysres.getString(void 0,key)).toString()};switch(this.meridiems){case"chinese":result=[{name:_getSysString.call(this,"azh0"),start:"00:00",end:"05:59"},{name:_getSysString.call(this,"azh1"),start:"06:00",end:"08:59"},{name:_getSysString.call(this,"azh2"),start:"09:00",end:"11:59"},{name:_getSysString.call(this,"azh3"),start:"12:00",end:"12:59"},{name:_getSysString.call(this,"azh4"),start:"13:00",end:"17:59"},{name:_getSysString.call(this,"azh5"),start:"18:00",end:"20:59"},{name:_getSysString.call(this,"azh6"),start:"21:00",end:"23:59"}];break;case"ethiopic":result=[{name:_getSysString.call(this,"a0-ethiopic"),start:"00:00",end:"05:59"},{name:_getSysString.call(this,"a1-ethiopic"),start:"06:00",end:"06:00"},{name:_getSysString.call(this,"a2-ethiopic"),start:"06:01",end:"11:59"},{name:_getSysString.call(this,"a3-ethiopic"),start:"12:00",end:"17:59"},{name:_getSysString.call(this,"a4-ethiopic"),start:"18:00",end:"23:59"}];break;default:result=[{name:_getSysString.call(this,"a0"),start:"00:00",end:"11:59"},{name:_getSysString.call(this,"a1"),start:"12:00",end:"23:59"}]}return result},_findMeridiem:function(hours,minutes){var range=this.info.dayPeriods;if(!range)return"";for(var minuteOfDay=60*hours+minutes,shortest={name:"",length:2e3},i=0;i<range.length;i++){var period=range[i];if(minuteOfDay===period.at||minuteOfDay>=period.from&&minuteOfDay<period.to){var periodCode="B"+i,length=void 0!==period.at?0:period.to-period.from;length<shortest.length&&(shortest={name:this.sysres.getString(void 0,periodCode+"-"+this.calName)||this.sysres.getString(void 0,periodCode),length:length})}}return shortest.name},_getTemplate:function(prefix,calendar){return"gregorian"!==calendar?prefix+"-"+calendar:prefix},getMonthsOfYear:function(options){var date,monthCount,length=options&&options.length||this.getLength(),template=DateFmt.monthNameLenMap[length],months=[void 0];options&&(options.date&&(date=DateFactory._dateToIlib(options.date)),options.year&&(date=DateFactory({year:options.year,month:1,day:1,type:this.cal.getType()}))),date||(date=DateFactory({calendar:this.cal.getType()})),monthCount=this.cal.getNumMonths(date.getYears());for(var i=1;i<=monthCount;i++)months[i]=this.sysres.getString(this._getTemplate(template+i,this.cal.getType())).toString();return months},getDaysOfWeek:function(options){for(var length=options&&options.length||this.getLength(),template=DateFmt.weekDayLenMap[length],days=[],i=0;i<7;i++)days[i]=this.sysres.getString(this._getTemplate(template+i,this.cal.getType())).toString();return days},toString:function(){return this.getTemplate()},_formatTemplate:function(date,templateArr){var i,key,temp,str="";for(i=0;i<templateArr.length;i++)switch(templateArr[i]){case"d":str+=date.day||1;break;case"dd":str+=JSUtils.pad(date.day||"1",2);break;case"yy":temp=""+(date.year||0)%100,str+=JSUtils.pad(temp,2);break;case"yyyy":str+=JSUtils.pad(date.year||"0",4);break;case"M":str+=date.month||1;break;case"MM":str+=JSUtils.pad(date.month||"1",2);break;case"h":0==(temp=(date.hour||0)%12)&&(temp="12"),str+=temp;break;case"hh":0==(temp=(date.hour||0)%12)&&(temp="12"),str+=JSUtils.pad(temp,2);break;case"K":str+=temp=(date.hour||0)%12;break;case"KK":temp=(date.hour||0)%12,str+=JSUtils.pad(temp,2);break;case"H":str+=date.hour||"0";break;case"HH":str+=JSUtils.pad(date.hour||"0",2);break;case"k":str+=0==date.hour?"24":date.hour;break;case"kk":temp=0==date.hour?"24":date.hour,str+=JSUtils.pad(temp,2);break;case"m":str+=date.minute||"0";break;case"mm":str+=JSUtils.pad(date.minute||"0",2);break;case"s":str+=date.second||"0";break;case"ss":str+=JSUtils.pad(date.second||"0",2);break;case"S":str+=date.millisecond||"0";break;case"SSS":str+=JSUtils.pad(date.millisecond||"0",3);break;case"N":case"NN":case"MMM":case"MMMM":case"L":case"LL":case"LLL":case"LLLL":key=templateArr[i]+(date.month||1),str+=this.sysres.getString(void 0,key+"-"+this.calName)||this.sysres.getString(void 0,key)||this.sysres.getString(void 0,key.replace(/L/g,"M")+"-"+this.calName)||this.sysres.getString(void 0,key.replace(/L/g,"M"));break;case"E":case"EE":case"EEE":case"EEEE":case"c":case"cc":case"ccc":case"cccc":key=templateArr[i]+date.getDayOfWeek(),str+=this.sysres.getString(void 0,key+"-"+this.calName)||this.sysres.getString(void 0,key);break;case"a":switch(this.meridiems){case"chinese":key=date.hour<6?"azh0":date.hour<9?"azh1":date.hour<12?"azh2":date.hour<13?"azh3":date.hour<18?"azh4":date.hour<21?"azh5":"azh6";break;case"ethiopic":date.hour<6?key="a0-ethiopic":6===date.hour&&0===date.minute?key="a1-ethiopic":6<=date.hour&&date.hour<12?key="a2-ethiopic":12<=date.hour&&date.hour<18?key="a3-ethiopic":18<=date.hour&&(key="a4-ethiopic");break;default:key=date.hour<12?"a0":"a1"}str+=this.sysres.getString(void 0,key+"-"+this.calName)||this.sysres.getString(void 0,key);break;case"B":str+=this._findMeridiem(date.hour,date.minute);break;case"w":str+=date.getWeekOfYear();break;case"ww":str+=JSUtils.pad(date.getWeekOfYear(),2);break;case"D":str+=date.getDayOfYear();break;case"DD":str+=JSUtils.pad(date.getDayOfYear(),2);break;case"DDD":str+=JSUtils.pad(date.getDayOfYear(),3);break;case"W":str+=date.getWeekOfMonth(this.locale);break;case"G":key="G"+date.getEra(),str+=this.sysres.getString(void 0,key+"-"+this.calName)||this.sysres.getString(void 0,key);break;case"O":str+=(temp=this.sysres.getString("1#1st|2#2nd|3#3rd|21#21st|22#22nd|23#23rd|31#31st|#{num}th","ordinalChoice")).formatChoice(date.day,{num:date.day},!1);break;case"z":str+=this.getTimeZone().getDisplayName(date,"standard");break;case"Z":str+=this.getTimeZone().getDisplayName(date,"rfc822");break;default:str+=templateArr[i].replace(/'/g,"")}return this.digits&&(str=JSUtils.mapString(str,this.digits)),str},format:function(dateLike){var thisZoneName=this.tz&&this.tz.getId()||"local",date=DateFactory._dateToIlib(dateLike,thisZoneName,this.locale);if(!(date.getCalendar&&date instanceof IDate))throw"Wrong date type passed to DateFmt.format()";if(this.useIntl&&this.IntlDateTimeObj){var jsDate=DateFactory._ilibToDate(date,thisZoneName,this.locale);return this.IntlDateTimeObj.format(jsDate)}(date.timezone||"local")===thisZoneName&&date.getCalendar()===this.calName||(date=DateFactory({type:this.calName,timezone:thisZoneName,julianday:date.getJulianDay()}));return this._formatTemplate(date,this.templateArr)},formatRelative:function(reference,date){var fmt,diff,absDiff,num;if(reference=DateFactory._dateToIlib(reference),date=DateFactory._dateToIlib(date),"object"!=typeof reference||!reference.getCalendar||reference.getCalendar()!==this.calName||"object"!=typeof date||!date.getCalendar||date.getCalendar()!==this.calName)throw"Wrong calendar type";if(diff=reference.getRataDie()-date.getRataDie(),(absDiff=Math.abs(diff))<694444e-9)switch(num=Math.round(86400*absDiff),this.length){case"s":fmt=0<diff?this.sysres.getString("#{num}s ago"):this.sysres.getString("#in {num}s");break;case"m":fmt=0<diff?this.sysres.getString("1#1 sec ago|#{num} sec ago"):this.sysres.getString("1#in 1 sec|#in {num} sec");break;default:case"f":case"l":fmt=0<diff?this.sysres.getString("1#1 second ago|#{num} seconds ago"):this.sysres.getString("1#in 1 second|#in {num} seconds")}else if(absDiff<.041666667)switch(num=Math.round(1440*absDiff),this.length){case"s":fmt=0<diff?this.sysres.getString("#{num}mi ago"):this.sysres.getString("#in {num}mi");break;case"m":fmt=0<diff?this.sysres.getString("1#1 min ago|#{num} min ago"):this.sysres.getString("1#in 1 min|#in {num} min");break;default:case"f":case"l":fmt=0<diff?this.sysres.getString("1#1 minute ago|#{num} minutes ago"):this.sysres.getString("1#in 1 minute|#in {num} minutes")}else if(absDiff<1)switch(num=Math.round(24*absDiff),this.length){case"s":fmt=0<diff?this.sysres.getString("#{num}h ago"):this.sysres.getString("#in {num}h");break;case"m":fmt=0<diff?this.sysres.getString("1#1 hr ago|#{num} hrs ago"):this.sysres.getString("1#in 1 hr|#in {num} hrs");break;default:case"f":case"l":fmt=0<diff?this.sysres.getString("1#1 hour ago|#{num} hours ago"):this.sysres.getString("1#in 1 hour|#in {num} hours")}else if(absDiff<14)switch(num=Math.round(absDiff),this.length){case"s":fmt=0<diff?this.sysres.getString("#{num}d ago"):this.sysres.getString("#in {num}d");break;case"m":fmt=0<diff?this.sysres.getString("1#1 dy ago|#{num} dys ago"):this.sysres.getString("1#in 1 dy|#in {num} dys");break;default:case"f":case"l":fmt=0<diff?this.sysres.getString("1#1 day ago|#{num} days ago"):this.sysres.getString("1#in 1 day|#in {num} days")}else if(absDiff<84)switch(num=Math.round(absDiff/7),this.length){case"s":fmt=0<diff?this.sysres.getString("#{num}w ago"):this.sysres.getString("#in {num}w");break;case"m":fmt=0<diff?this.sysres.getString("1#1 wk ago|#{num} wks ago"):this.sysres.getString("1#in 1 wk|#in {num} wks");break;default:case"f":case"l":fmt=0<diff?this.sysres.getString("1#1 week ago|#{num} weeks ago"):this.sysres.getString("1#in 1 week|#in {num} weeks")}else if(absDiff<730)switch(num=Math.round(absDiff/30.4),this.length){case"s":fmt=0<diff?this.sysres.getString("#{num}mo ago"):this.sysres.getString("#in {num}mo");break;case"m":fmt=0<diff?this.sysres.getString("1#1 mon ago|#{num} mons ago"):this.sysres.getString("1#in 1 mon|#in {num} mons");break;default:case"f":case"l":fmt=0<diff?this.sysres.getString("1#1 month ago|#{num} months ago"):this.sysres.getString("1#in 1 month|#in {num} months")}else switch(num=Math.round(absDiff/365),this.length){case"s":fmt=0<diff?this.sysres.getString("#{num}y ago"):this.sysres.getString("#in {num}y");break;case"m":fmt=0<diff?this.sysres.getString("1#1 yr ago|#{num} yrs ago"):this.sysres.getString("1#in 1 yr|#in {num} yrs");break;default:case"f":case"l":fmt=0<diff?this.sysres.getString("1#1 year ago|#{num} years ago"):this.sysres.getString("1#in 1 year|#in {num} years")}return fmt.formatChoice(num,{num:num})}},module.exports=DateFmt;
|
|
2
|
+
var ilib=require("../index.js"),Utils=require("./Utils.js"),JSUtils=require("./JSUtils.js"),Locale=require("./Locale.js"),LocaleInfo=require("./LocaleInfo.js"),IDate=require("./IDate.js"),DateFactory=require("./DateFactory.js"),CalendarFactory=require("./CalendarFactory.js"),ResBundle=require("./ResBundle.js"),TimeZone=require("./TimeZone.js"),GregorianCal=require("./GregorianCal.js"),ISet=require("./ISet.js"),DateFmt=function(options){var c,comps,loadParams,sync=!0;if(this.locale=new Locale(),this.type="date",this.length="s",this.dateComponents="dmy",this.timeComponents="ahm",this.meridiems="default",this.useIntl=!1,(options=options||{sync:!0}).locale&&(this.locale="string"==typeof options.locale?new Locale(options.locale):options.locale),!options.type||"date"!==options.type&&"time"!==options.type&&"datetime"!==options.type||(this.type=options.type),options.calendar&&(this.calName=options.calendar),!options.length||"short"!==options.length&&"medium"!==options.length&&"long"!==options.length&&"full"!==options.length||(this.length=options.length.charAt(0)),options.date){for(var arr=options.date.split(""),dateComps=new ISet(),bad=!1,i=0;i<arr.length;i++)if("d"!==(c="e"===(c=arr[i].toLowerCase())?"w":c)&&"m"!==c&&"y"!==c&&"w"!==c&&"n"!==c){if("h"!==c&&"m"!==c&&"s"!==c&&"a"!==c&&"z"!==c&&"g"!==c){bad=!0;break}}else dateComps.add(c);bad||(comps=dateComps.asArray().sort(function(left,right){return left<right?-1:right<left?1:0}),this.dateComponents=comps.join(""))}if(options.time){arr=options.time.split("");var timeComps=new ISet();for(this.badTime=!1,i=0;i<arr.length;i++)if("h"!==(c=arr[i].toLowerCase())&&"m"!==c&&"s"!==c&&"a"!==c&&"z"!==c){if("d"!==c&&"m"!==c&&"y"!==c&&"w"!==c&&"e"!==c&&"n"!==c&&"g"!==c){this.badTime=!0;break}}else timeComps.add(c);this.badTime||(comps=timeComps.asArray().sort(function(left,right){return left<right?-1:right<left?1:0}),this.timeComponents=comps.join(""))}!options.clock||"12"!==options.clock&&"24"!==options.clock||(this.clock=options.clock),options.template&&(this.type="",this.length="",this.dateComponents="",this.timeComponents="",this.template=options.template),options.timezone&&(options.timezone instanceof TimeZone?(this.tz=options.timezone,this.timezone=this.tz.getId()):this.timezone=options.timezone),"boolean"==typeof options.useNative&&(this.useNative=options.useNative),void 0===options.meridiems||"chinese"!==options.meridiems&&"gregorian"!==options.meridiems&&"ethiopic"!==options.meridiems||(this.meridiems=options.meridiems),void 0!==options.sync&&(sync=!0===options.sync),void 0!==options.useIntl&&(this.useIntl=options.useIntl),loadParams=options.loadParams,new LocaleInfo(this.locale,{sync:sync,loadParams:loadParams,onLoad:ilib.bind(this,function(li){var len;this.locinfo=li,this.calName=this.calName||this.locinfo.getCalendar()||"gregorian",this.useIntl&&"undefined"!=typeof Intl&&void 0!==Intl.DateTimeFormat&&void 0!==Intl.DateTimeFormat.supportedLocalesOf&&0<Intl.DateTimeFormat.supportedLocalesOf(this.locale.getSpec()).length&&"western"===this.locinfo.getDigitsStyle()&&!options.template&&"gregorian"===this.calName&&(len=DateFmt.lenmap[this.length],"date"===this.type&&("dmy"===this.dateComponents&&"full"!==len||"dmwy"===this.dateComponents&&"full"===len)?this.IntlDateTimeObj=new Intl.DateTimeFormat(this.locale.getSpec(),{dateStyle:len}):"time"===this.type&&"ahm"===this.timeComponents||"ahms"===this.timeComponents?this.IntlDateTimeObj=new Intl.DateTimeFormat(this.locale.getSpec(),{timeStyle:{ahm:"short",ahms:"medium"}[this.timeComponents]}):"date"===this.type&&"m"===this.dateComponents&&"full"===len?this.IntlDateTimeObj=new Intl.DateTimeFormat(this.locale.getSpec(),{month:"long"}):"date"===this.type&&"w"===this.dateComponents&&"full"===len?this.IntlDateTimeObj=new Intl.DateTimeFormat(this.locale.getSpec(),{weekday:"long"}):this.useIntl=!1),this.useIntl?"function"==typeof options.onLoad&&options.onLoad(this):(!this.IntlDateTimeObj&&ilib.isDynCode()&&DateFactory._init(this.calName),CalendarFactory({type:this.calName,sync:sync,loadParams:loadParams,onLoad:ilib.bind(this,function(cal){this.cal=cal,this.cal||(this.cal=new GregorianCal),"default"===this.meridiems&&(this.meridiems=li.getMeridiemsStyle()),new ResBundle({locale:this.locale,name:"sysres",sync:sync,loadParams:loadParams,onLoad:ilib.bind(this,function(rb){this.sysres=rb,this.tz?this._init(options):((rb=options.timezone)||options.locale||(rb="local"),new TimeZone({locale:this.locale,id:rb,sync:sync,loadParams:loadParams,onLoad:ilib.bind(this,function(tz){this.tz=tz,this._init(options)})}))})})})}))})})};DateFmt.lenmap={s:"short",m:"medium",l:"long",f:"full"},DateFmt.defaultFmt={gregorian:{order:"{date} {time}",date:{dmwy:"EEE d/MM/yyyy",dmy:"d/MM/yyyy",dmw:"EEE d/MM",dm:"d/MM",my:"MM/yyyy",dw:"EEE d",d:"dd",m:"MM",y:"yyyy",n:"NN",w:"EEE"},time:{12:"h:mm:ssa",24:"H:mm:ss"},range:{c00:"{st} - {et}, {sd}/{sm}/{sy}",c01:"{sd}/{sm} {st} - {ed}/{em} {et}, {sy}",c02:"{sd}/{sm} {st} - {ed}/{em} {et}, {sy}",c03:"{sd}/{sm}/{sy} {st} - {ed}/{em}/{ey} {et}",c10:"{sd}-{ed}/{sm}/{sy}",c11:"{sd}/{sm} - {ed}/{em} {sy}",c12:"{sd}/{sm}/{sy} - {ed}/{em}/{ey}",c20:"{sm}/{sy} - {em}/{ey}",c30:"{sy} - {ey}"}},islamic:"gregorian",hebrew:"gregorian",julian:"gregorian",buddhist:"gregorian",persian:"gregorian","persian-algo":"gregorian",han:"gregorian"},DateFmt.monthNameLenMap={short:"N",medium:"NN",long:"MMM",full:"MMMM"},DateFmt.weekDayLenMap={short:"E",medium:"EE",long:"EEE",full:"EEEE"},DateFmt.getMeridiemsRange=function(options){options=options||{sync:!0};var args=JSUtils.merge({},options);return args.onLoad=function(fmt){"function"==typeof options.onLoad&&options.onLoad(fmt.getMeridiemsRange())},new DateFmt(args).getMeridiemsRange()},DateFmt.isIntlDateTimeAvailable=function(locale){return!(!locale||!ilib._global("Intl")||void 0===Intl.DateTimeFormat||void 0===Intl.DateTimeFormat.supportedLocalesOf)&&0<Intl.DateTimeFormat.supportedLocalesOf(locale).length},DateFmt.prototype={_init:function(options){void 0===options.sync&&(options.sync=!0),Utils.loadData({object:"DateFmt",locale:this.locale,name:"dateformats.json",sync:options.sync,loadParams:options.loadParams,callback:ilib.bind(this,function(formats){formats=formats||ilib.data.dateformats||DateFmt.defaultFmt,this.info=formats;var ret=this;if(this.template)this._massageTemplate();else if(void 0===this.clock&&(this.clock=this.locinfo.getClock()),"boolean"!=typeof options.sync||options.sync)this._initTemplate(formats),this._massageTemplate();else try{this._initTemplate(formats),this._massageTemplate()}catch(e){ret=void 0}"function"==typeof options.onLoad&&options.onLoad(ret)})})},_initTemplate:function(formats){if(!formats[this.calName])throw"No formats available for calendar "+this.calName+" in locale "+this.locale.toString();var name=formats[this.calName];switch(this.formats="string"==typeof name?formats[name]:name,this.template="",this.type){case"datetime":this.template=this.formats&&this._getLengthFormat(this.formats.order,this.length)||"{date} {time}",this.template=this.template.replace("{date}",this._getFormat(this.formats.date,this.dateComponents,this.length)||""),this.template=this.template.replace("{time}",this._getFormat(this.formats.time[this.clock],this.timeComponents,this.length)||"");break;case"date":this.template=this._getFormat(this.formats.date,this.dateComponents,this.length);break;case"time":this.template=this._getFormat(this.formats.time[this.clock],this.timeComponents,this.length)}this.componentOrder=this._getFormat(this.formats.date,"dmy","l").replace(/[^dMy]/g,"").replace(/y+/,"y").replace(/d+/,"d").replace(/M+/,"m")},_massageTemplate:function(){var i,digits;if(this.clock&&this.template){var temp="";switch(this.clock){case"24":for(i=0;i<this.template.length;i++)if("'"==this.template.charAt(i)){for(temp+=this.template.charAt(i++);i<this.template.length&&"'"!==this.template.charAt(i);)temp+=this.template.charAt(i++);i<this.template.length&&(temp+=this.template.charAt(i))}else"K"==this.template.charAt(i)?temp+="k":"h"==this.template.charAt(i)?temp+="H":temp+=this.template.charAt(i);this.template=temp;break;case"12":for(i=0;i<this.template.length;i++)if("'"==this.template.charAt(i)){for(temp+=this.template.charAt(i++);i<this.template.length&&"'"!==this.template.charAt(i);)temp+=this.template.charAt(i++);i<this.template.length&&(temp+=this.template.charAt(i))}else"k"==this.template.charAt(i)?temp+="K":"H"==this.template.charAt(i)?temp+="h":temp+=this.template.charAt(i);this.template=temp}}this.templateArr=this._tokenize(this.template),"boolean"==typeof this.useNative?this.useNative&&(digits=this.locinfo.getNativeDigits())&&(this.digits=digits):"native"===this.locinfo.getDigitsStyle()&&(digits=this.locinfo.getNativeDigits())&&(this.useNative=!0,this.digits=digits)},_tokenize:function(template){var start,ch,letter,i=0,arr=[];if(template)for(;i<template.length;){if(start=i,"'"===(ch=template.charAt(i))){for(i++;i<template.length&&"'"!==template.charAt(i);)i++;i<template.length&&i++}else if("a"<=ch&&ch<="z"||"A"<=ch&&ch<="Z")for(letter=template.charAt(i);i<template.length&&ch===letter;)ch=template.charAt(++i);else for(;i<template.length&&"'"!==ch&&(ch<"a"||"z"<ch)&&(ch<"A"||"Z"<ch);)ch=template.charAt(++i);arr.push(template.substring(start,i))}return arr},_getFormatInternal:function getFormatInternal(obj,components,length){if(void 0!==components&&obj&&obj[components])return this._getLengthFormat(obj[components],length)},_standAlones:{m:"l",my:"mys",d:"a",w:"e",y:"r"},_getFormat:function getFormat(obj,components,length){if(components&&this._standAlones[components]){var tmp=this._getFormatInternal(obj,this._standAlones[components],length);if(tmp)return tmp}return this._getFormatInternal(obj,components,length)},_getLengthFormat:function getLengthFormat(obj,length){return"string"==typeof obj?obj:obj[length]||void 0},getLocale:function(){return this.locale},getTemplate:function(){return this.template},getDateComponentOrder:function(){return this.componentOrder},getType:function(){return this.type},getCalendar:function(){return this.cal.getType()||"gregorian"},getLength:function(){return DateFmt.lenmap[this.length]||""},getDateComponents:function(){return this.dateComponents||""},getTimeComponents:function(){return this.timeComponents||""},getTimeZone:function(){return this.tz},getClock:function(){return this.clock||this.locinfo.getClock()},getMeridiemsRange:function(){function _getSysString(key){return(this.sysres.getString(void 0,key+"-"+this.calName)||this.sysres.getString(void 0,key)).toString()}var result;switch(this.meridiems){case"chinese":result=[{name:_getSysString.call(this,"azh0"),start:"00:00",end:"05:59"},{name:_getSysString.call(this,"azh1"),start:"06:00",end:"08:59"},{name:_getSysString.call(this,"azh2"),start:"09:00",end:"11:59"},{name:_getSysString.call(this,"azh3"),start:"12:00",end:"12:59"},{name:_getSysString.call(this,"azh4"),start:"13:00",end:"17:59"},{name:_getSysString.call(this,"azh5"),start:"18:00",end:"20:59"},{name:_getSysString.call(this,"azh6"),start:"21:00",end:"23:59"}];break;case"ethiopic":result=[{name:_getSysString.call(this,"a0-ethiopic"),start:"00:00",end:"05:59"},{name:_getSysString.call(this,"a1-ethiopic"),start:"06:00",end:"06:00"},{name:_getSysString.call(this,"a2-ethiopic"),start:"06:01",end:"11:59"},{name:_getSysString.call(this,"a3-ethiopic"),start:"12:00",end:"17:59"},{name:_getSysString.call(this,"a4-ethiopic"),start:"18:00",end:"23:59"}];break;default:result=[{name:_getSysString.call(this,"a0"),start:"00:00",end:"11:59"},{name:_getSysString.call(this,"a1"),start:"12:00",end:"23:59"}]}return result},_findMeridiem:function(hours,minutes){var range=this.info.dayPeriods;if(!range)return"";for(var minuteOfDay=60*hours+minutes,shortest={name:"",length:2e3},i=0;i<range.length;i++){var periodCode,period=range[i];(minuteOfDay===period.at||minuteOfDay>=period.from&&minuteOfDay<period.to)&&(periodCode="B"+i,(period=void 0!==period.at?0:period.to-period.from)<shortest.length)&&(shortest={name:this.sysres.getString(void 0,periodCode+"-"+this.calName)||this.sysres.getString(void 0,periodCode),length:period})}return shortest.name},_getTemplate:function(prefix,calendar){return"gregorian"!==calendar?prefix+"-"+calendar:prefix},getMonthsOfYear:function(options){for(var length=options&&options.length||this.getLength(),template=DateFmt.monthNameLenMap[length],months=[void 0],date=(date=options&&(options.date&&(date=DateFactory._dateToIlib(options.date)),options.year)?DateFactory({year:options.year,month:1,day:1,type:this.cal.getType()}):date)||DateFactory({calendar:this.cal.getType()}),monthCount=this.cal.getNumMonths(date.getYears()),i=1;i<=monthCount;i++)months[i]=this.sysres.getString(this._getTemplate(template+i,this.cal.getType())).toString();return months},getDaysOfWeek:function(options){for(var options=options&&options.length||this.getLength(),template=DateFmt.weekDayLenMap[options],days=[],i=0;i<7;i++)days[i]=this.sysres.getString(this._getTemplate(template+i,this.cal.getType())).toString();return days},toString:function(){return this.getTemplate()},_formatTemplate:function(date,templateArr){for(var key,temp,str="",i=0;i<templateArr.length;i++)switch(templateArr[i]){case"d":str+=date.day||1;break;case"dd":str+=JSUtils.pad(date.day||"1",2);break;case"yy":temp=""+(date.year||0)%100,str+=JSUtils.pad(temp,2);break;case"yyyy":str+=JSUtils.pad(date.year||"0",4);break;case"M":str+=date.month||1;break;case"MM":str+=JSUtils.pad(date.month||"1",2);break;case"h":str+=temp=0==(temp=(date.hour||0)%12)?"12":temp;break;case"hh":0==(temp=(date.hour||0)%12)&&(temp="12"),str+=JSUtils.pad(temp,2);break;case"K":str+=temp=(date.hour||0)%12;break;case"KK":temp=(date.hour||0)%12,str+=JSUtils.pad(temp,2);break;case"H":str+=date.hour||"0";break;case"HH":str+=JSUtils.pad(date.hour||"0",2);break;case"k":str+=0==date.hour?"24":date.hour;break;case"kk":temp=0==date.hour?"24":date.hour,str+=JSUtils.pad(temp,2);break;case"m":str+=date.minute||"0";break;case"mm":str+=JSUtils.pad(date.minute||"0",2);break;case"s":str+=date.second||"0";break;case"ss":str+=JSUtils.pad(date.second||"0",2);break;case"S":str+=date.millisecond||"0";break;case"SSS":str+=JSUtils.pad(date.millisecond||"0",3);break;case"N":case"NN":case"MMM":case"MMMM":case"L":case"LL":case"LLL":case"LLLL":key=templateArr[i]+(date.month||1),str+=this.sysres.getString(void 0,key+"-"+this.calName)||this.sysres.getString(void 0,key)||this.sysres.getString(void 0,key.replace(/L/g,"M")+"-"+this.calName)||this.sysres.getString(void 0,key.replace(/L/g,"M"));break;case"E":case"EE":case"EEE":case"EEEE":case"c":case"cc":case"ccc":case"cccc":key=templateArr[i]+date.getDayOfWeek(),str+=this.sysres.getString(void 0,key+"-"+this.calName)||this.sysres.getString(void 0,key);break;case"a":switch(this.meridiems){case"chinese":key=date.hour<6?"azh0":date.hour<9?"azh1":date.hour<12?"azh2":date.hour<13?"azh3":date.hour<18?"azh4":date.hour<21?"azh5":"azh6";break;case"ethiopic":date.hour<6?key="a0-ethiopic":6===date.hour&&0===date.minute?key="a1-ethiopic":6<=date.hour&&date.hour<12?key="a2-ethiopic":12<=date.hour&&date.hour<18?key="a3-ethiopic":18<=date.hour&&(key="a4-ethiopic");break;default:key=date.hour<12?"a0":"a1"}str+=this.sysres.getString(void 0,key+"-"+this.calName)||this.sysres.getString(void 0,key);break;case"B":str+=this._findMeridiem(date.hour,date.minute);break;case"w":str+=date.getWeekOfYear();break;case"ww":str+=JSUtils.pad(date.getWeekOfYear(),2);break;case"D":str+=date.getDayOfYear();break;case"DD":str+=JSUtils.pad(date.getDayOfYear(),2);break;case"DDD":str+=JSUtils.pad(date.getDayOfYear(),3);break;case"W":str+=date.getWeekOfMonth(this.locale);break;case"G":key="G"+date.getEra(),str+=this.sysres.getString(void 0,key+"-"+this.calName)||this.sysres.getString(void 0,key);break;case"O":str+=(temp=this.sysres.getString("1#1st|2#2nd|3#3rd|21#21st|22#22nd|23#23rd|31#31st|#{num}th","ordinalChoice")).formatChoice(date.day,{num:date.day},!1);break;case"z":str+=this.getTimeZone().getDisplayName(date,"standard");break;case"Z":str+=this.getTimeZone().getDisplayName(date,"rfc822");break;default:str+=templateArr[i].replace(/'/g,"")}return str=this.digits?JSUtils.mapString(str,this.digits):str},format:function(dateLike){var jsDate,thisZoneName=this.tz&&this.tz.getId()||"local",dateLike=DateFactory._dateToIlib(dateLike,thisZoneName,this.locale);if(dateLike.getCalendar&&dateLike instanceof IDate)return this.useIntl&&this.IntlDateTimeObj?(jsDate=DateFactory._ilibToDate(dateLike,thisZoneName,this.locale),this.IntlDateTimeObj.format(jsDate)):((dateLike.timezone||"local")===thisZoneName&&dateLike.getCalendar()===this.calName||(dateLike=DateFactory({type:this.calName,timezone:thisZoneName,julianday:dateLike.getJulianDay()})),this._formatTemplate(dateLike,this.templateArr));throw"Wrong date type passed to DateFmt.format()"},formatRelative:function(reference,date){var fmt,diff,num;if(reference=DateFactory._dateToIlib(reference),date=DateFactory._dateToIlib(date),"object"!=typeof reference||!reference.getCalendar||reference.getCalendar()!==this.calName||"object"!=typeof date||!date.getCalendar||date.getCalendar()!==this.calName)throw"Wrong calendar type";if(diff=reference.getRataDie()-date.getRataDie(),(reference=Math.abs(diff))<694444e-9)switch(num=Math.round(86400*reference),this.length){case"s":fmt=0<diff?this.sysres.getString("#{num}s ago"):this.sysres.getString("#in {num}s");break;case"m":fmt=0<diff?this.sysres.getString("1#1 sec ago|#{num} sec ago"):this.sysres.getString("1#in 1 sec|#in {num} sec");break;default:case"f":case"l":fmt=0<diff?this.sysres.getString("1#1 second ago|#{num} seconds ago"):this.sysres.getString("1#in 1 second|#in {num} seconds")}else if(reference<.041666667)switch(num=Math.round(1440*reference),this.length){case"s":fmt=0<diff?this.sysres.getString("#{num}mi ago"):this.sysres.getString("#in {num}mi");break;case"m":fmt=0<diff?this.sysres.getString("1#1 min ago|#{num} min ago"):this.sysres.getString("1#in 1 min|#in {num} min");break;default:case"f":case"l":fmt=0<diff?this.sysres.getString("1#1 minute ago|#{num} minutes ago"):this.sysres.getString("1#in 1 minute|#in {num} minutes")}else if(reference<1)switch(num=Math.round(24*reference),this.length){case"s":fmt=0<diff?this.sysres.getString("#{num}h ago"):this.sysres.getString("#in {num}h");break;case"m":fmt=0<diff?this.sysres.getString("1#1 hr ago|#{num} hrs ago"):this.sysres.getString("1#in 1 hr|#in {num} hrs");break;default:case"f":case"l":fmt=0<diff?this.sysres.getString("1#1 hour ago|#{num} hours ago"):this.sysres.getString("1#in 1 hour|#in {num} hours")}else if(reference<14)switch(num=Math.round(reference),this.length){case"s":fmt=0<diff?this.sysres.getString("#{num}d ago"):this.sysres.getString("#in {num}d");break;case"m":fmt=0<diff?this.sysres.getString("1#1 dy ago|#{num} dys ago"):this.sysres.getString("1#in 1 dy|#in {num} dys");break;default:case"f":case"l":fmt=0<diff?this.sysres.getString("1#1 day ago|#{num} days ago"):this.sysres.getString("1#in 1 day|#in {num} days")}else if(reference<84)switch(num=Math.round(reference/7),this.length){case"s":fmt=0<diff?this.sysres.getString("#{num}w ago"):this.sysres.getString("#in {num}w");break;case"m":fmt=0<diff?this.sysres.getString("1#1 wk ago|#{num} wks ago"):this.sysres.getString("1#in 1 wk|#in {num} wks");break;default:case"f":case"l":fmt=0<diff?this.sysres.getString("1#1 week ago|#{num} weeks ago"):this.sysres.getString("1#in 1 week|#in {num} weeks")}else if(reference<730)switch(num=Math.round(reference/30.4),this.length){case"s":fmt=0<diff?this.sysres.getString("#{num}mo ago"):this.sysres.getString("#in {num}mo");break;case"m":fmt=0<diff?this.sysres.getString("1#1 mon ago|#{num} mons ago"):this.sysres.getString("1#in 1 mon|#in {num} mons");break;default:case"f":case"l":fmt=0<diff?this.sysres.getString("1#1 month ago|#{num} months ago"):this.sysres.getString("1#in 1 month|#in {num} months")}else switch(num=Math.round(reference/365),this.length){case"s":fmt=0<diff?this.sysres.getString("#{num}y ago"):this.sysres.getString("#in {num}y");break;case"m":fmt=0<diff?this.sysres.getString("1#1 yr ago|#{num} yrs ago"):this.sysres.getString("1#in 1 yr|#in {num} yrs");break;default:case"f":case"l":fmt=0<diff?this.sysres.getString("1#1 year ago|#{num} years ago"):this.sysres.getString("1#in 1 year|#in {num} years")}return fmt.formatChoice(num,{num:num})}},module.exports=DateFmt;
|
package/lib/DateRngFmt.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// !data dateformats sysres
|
|
2
|
-
var ilib=require("../index.js"),JSUtils=require("./JSUtils.js"),Locale=require("./Locale.js"),CalendarFactory=require("./CalendarFactory.js"),DateFmt=require("./DateFmt.js"),IString=require("./IString.js"),GregorianCal=require("./GregorianCal.js"),DateFactory=require("./DateFactory.js"),DateRngFmt=function(options){var sync=!0,loadParams=void 0
|
|
2
|
+
var ilib=require("../index.js"),JSUtils=require("./JSUtils.js"),Locale=require("./Locale.js"),CalendarFactory=require("./CalendarFactory.js"),DateFmt=require("./DateFmt.js"),IString=require("./IString.js"),GregorianCal=require("./GregorianCal.js"),DateFactory=require("./DateFactory.js"),DateRngFmt=function(options){var sync=!0,loadParams=void 0,opts=(this.locale=new Locale(),this.length="s",options&&(options.locale&&(this.locale="string"==typeof options.locale?new Locale(options.locale):options.locale),options.calendar&&(this.calName=options.calendar),!options.length||"short"!==options.length&&"medium"!==options.length&&"long"!==options.length&&"full"!==options.length||(this.length=options.length.charAt(0)),options.timezone&&(this.timezone=options.timezone),void 0!==options.sync&&(sync=!!options.sync),loadParams=options.loadParams),{});JSUtils.shallowCopy(options,opts),opts.sync=sync,opts.loadParams=loadParams,opts.onLoad=ilib.bind(this,function(fmt){if(this.dateFmt=fmt)this.locinfo=this.dateFmt.locinfo,this.calName=this.calName||this.locinfo.getCalendar()||"gregorian",CalendarFactory({type:this.calName,sync:sync,loadParams:loadParams,onLoad:ilib.bind(this,function(cal){this.cal=cal,this.cal||(this.cal=new GregorianCal),this.timeTemplate=this.dateFmt._getFormat(this.dateFmt.formats.time[this.dateFmt.clock],this.dateFmt.timeComponents,this.length)||"hh:mm",this.timeTemplateArr=this.dateFmt._tokenize(this.timeTemplate),options&&"function"==typeof options.onLoad&&options.onLoad(this)})});else{if(!options||"boolean"!=typeof options.sync||options.sync||"function"!=typeof options.onLoad)throw"No formats available for calendar "+this.calName+" in locale "+this.locale.getSpec();options.onLoad(void 0)}}),new DateFmt(opts)};DateRngFmt.prototype={getLocale:function(){return this.locale},getCalendar:function(){return this.dateFmt.getCalendar()},getLength:function(){return DateFmt.lenmap[this.length]||""},getTimeZone:function(){return this.dateFmt.getTimeZone()},getClock:function(){return this.dateFmt.getClock()},format:function(startDateLike,endDateLike){var yearTemplate,monthTemplate,dayTemplate,formats,endRd,tmp,fmt="",thisZoneName=this.dateFmt.tz&&this.dateFmt.tz.getId()||"local",startDateLike=DateFactory._dateToIlib(startDateLike,thisZoneName,this.locale),endDateLike=DateFactory._dateToIlib(endDateLike,thisZoneName,this.locale);return("object"!=typeof startDateLike||!startDateLike.getCalendar||startDateLike.getCalendar()!==this.calName||this.timezone&&startDateLike.timezone&&startDateLike.timezone!==this.timezone)&&(startDateLike=DateFactory({type:this.calName,timezone:thisZoneName,julianday:startDateLike.getJulianDay()})),("object"!=typeof endDateLike||!endDateLike.getCalendar||endDateLike.getCalendar()!==this.calName||this.timezone&&endDateLike.timezone&&endDateLike.timezone!==this.timezone)&&(endDateLike=DateFactory({type:this.calName,timezone:thisZoneName,julianday:endDateLike.getJulianDay()})),thisZoneName=startDateLike.getRataDie(),endRd=endDateLike.getRataDie(),formats=this.dateFmt.formats.date,yearTemplate=this.dateFmt._tokenize(this.dateFmt._getFormatInternal(formats,"y",this.length)||"yyyy"),monthTemplate=this.dateFmt._tokenize(this.dateFmt._getFormatInternal(formats,"m",this.length)||"MM"),dayTemplate=this.dateFmt._tokenize(this.dateFmt._getFormatInternal(formats,"d",this.length)||"dd"),endRd-thisZoneName<3?fmt=startDateLike.year===endDateLike.year?startDateLike.month===endDateLike.month?startDateLike.day===endDateLike.day?new IString(this.dateFmt._getFormat(this.dateFmt.formats.range,"c00",this.length)):new IString(this.dateFmt._getFormat(this.dateFmt.formats.range,"c01",this.length)):new IString(this.dateFmt._getFormat(this.dateFmt.formats.range,"c02",this.length)):new IString(this.dateFmt._getFormat(this.dateFmt.formats.range,"c03",this.length)):endRd-thisZoneName<730?fmt=startDateLike.year===endDateLike.year?startDateLike.month===endDateLike.month?new IString(this.dateFmt._getFormat(this.dateFmt.formats.range,"c10",this.length)):new IString(this.dateFmt._getFormat(this.dateFmt.formats.range,"c11",this.length)):new IString(this.dateFmt._getFormat(this.dateFmt.formats.range,"c12",this.length)):endRd-thisZoneName<3650?(fmt=new IString(this.dateFmt._getFormat(this.dateFmt.formats.range,"c20",this.length)),(tmp=this.dateFmt._getFormatInternal(formats,"mys",this.length))&&(-1<tmp.indexOf("r")&&(endRd=this.dateFmt._getFormatInternal(formats,"r",this.length))&&(yearTemplate=this.dateFmt._tokenize(endRd)),-1<tmp.indexOf("L"))&&(thisZoneName=this.dateFmt._getFormatInternal(formats,"l",this.length))&&(monthTemplate=this.dateFmt._tokenize(thisZoneName))):(fmt=new IString(this.dateFmt._getFormat(this.dateFmt.formats.range,"c30",this.length)),(tmp=this.dateFmt._getFormatInternal(formats,"r",this.length))&&(yearTemplate=this.dateFmt._tokenize(tmp))),fmt.format({sy:this.dateFmt._formatTemplate(startDateLike,yearTemplate),sm:this.dateFmt._formatTemplate(startDateLike,monthTemplate),sd:this.dateFmt._formatTemplate(startDateLike,dayTemplate),st:this.dateFmt._formatTemplate(startDateLike,this.timeTemplateArr),ey:this.dateFmt._formatTemplate(endDateLike,yearTemplate),em:this.dateFmt._formatTemplate(endDateLike,monthTemplate),ed:this.dateFmt._formatTemplate(endDateLike,dayTemplate),et:this.dateFmt._formatTemplate(endDateLike,this.timeTemplateArr)})}},module.exports=DateRngFmt;
|