@alydev/adapter-hijri 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +20 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +131 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Calix contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @alydev/adapter-hijri
|
|
2
|
+
|
|
3
|
+
The Hijri (Umm al-Qura / Islamic civil) calendar adapter for
|
|
4
|
+
[Calix](https://github.com/calix-ui/calix-datepicker). Conversion is backed by
|
|
5
|
+
the platform's ICU `islamic-umalqura` calendar, so no lookup tables ship in the
|
|
6
|
+
bundle.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pnpm add @alydev/datepicker @alydev/adapter-hijri
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { DatePicker } from "@alydev/datepicker";
|
|
14
|
+
import { hijri } from "@alydev/adapter-hijri";
|
|
15
|
+
|
|
16
|
+
<DatePicker adapter={hijri} locale="ar-SA" dir="rtl" />;
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Stateless singleton — import once and share. Locale (`ar-SA`, `fa-IR`, `en-US`, …)
|
|
20
|
+
is always a parameter, so one adapter serves every Hijri locale.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@alydev/core"),c="islamic-umalqura",w=864e5,L=new Intl.DateTimeFormat("en-US-u-ca-islamic-umalqura-nu-latn",{year:"numeric",month:"numeric",day:"numeric",timeZone:"UTC"});function i(e,t,a){const n=L.formatToParts(new Date(Date.UTC(e,t-1,a,12)));let o=0,l=0,y=0;for(const u of n)u.type==="year"?o=Number(u.value.replace(/[^0-9]/g,"")):u.type==="month"?l=Number(u.value):u.type==="day"&&(y=Number(u.value));return{year:o,month:l,day:y}}function D(e){const t=new Date(e*w);return{y:t.getUTCFullYear(),m:t.getUTCMonth()+1,d:t.getUTCDate()}}function g(e){const t=D(e);return i(t.y,t.m,t.d)}function d(e){return e.year*354.36707+(e.month-1)*29.53059+e.day}function M(e,t){return e.year-t.year||e.month-t.month||e.day-t.day}const k=Math.floor(Date.UTC(2e3,0,1)/w),p=i(2e3,1,1);function r(e){let t=k+Math.round(d(e)-d(p));for(let n=0;n<4;n++){const o=Math.round(d(e)-d(g(t)));if(o===0)break;t+=o}let a=0;for(;M(g(t),e)<0&&a++<60;)t++;for(a=0;M(g(t),e)>0&&a++<60;)t--;return t}function Y(e,t){const a=D(r(e));return new Date(a.y,a.m-1,a.d,t?.hour??0,t?.minute??0,t?.second??0,t?.millisecond??0)}function f(e,t){const a=r({year:e,month:t,day:1});return r(t===12?{year:e+1,month:1,day:1}:{year:e,month:t+1,day:1})-a}function N(e){const t=D(r(e));return new Date(t.y,t.m-1,t.d).getDay()}function h(e,t){const a=i(new Date().getFullYear(),6,1).year,n=Array.from({length:12},(o,l)=>{const y=D(r({year:a,month:l+1,day:15}));return new Date(y.y,y.m-1,y.d)});return m.monthNamesFromDates(n,e,t,c)}const s={id:"hijri",defaultLocale:"ar-SA",today:()=>{const e=new Date;return i(e.getFullYear(),e.getMonth()+1,e.getDate())},toDate:(e,t)=>Y(e,t),fromDate:e=>i(e.getFullYear(),e.getMonth()+1,e.getDate()),addDays:(e,t)=>g(r(e)+t),addMonths:(e,t)=>{const a=e.month-1+t,n=e.year+Math.floor(a/12),o=(a%12+12)%12+1;return{year:n,month:o,day:Math.min(e.day,f(n,o))}},addYears:(e,t)=>{const a=e.year+t;return{year:a,month:e.month,day:Math.min(e.day,f(a,e.month))}},startOfMonth:e=>({year:e.year,month:e.month,day:1}),endOfMonth:e=>({year:e.year,month:e.month,day:f(e.year,e.month)}),daysInMonth:(e,t)=>f(e,t),monthsInYear:()=>12,isLeapYear:e=>r({year:e+1,month:1,day:1})-r({year:e,month:1,day:1})===355,getWeekday:e=>N(e),getMonthGrid:(e,t)=>m.generateMonthGrid(s,e,t),getYearRange:(e,t)=>{const a=Math.floor(t/2);return Array.from({length:t},(n,o)=>e-a+o)},getWeek:(e,{weekStartsOn:t})=>{const a={year:e.year,month:1,day:1},n=r(e)-r(a)+1,o=(N(a)-t+7)%7;return Math.floor((n+o-1)/7)+1},compare:(e,t)=>M(e,t),isSameDay:(e,t)=>e.year===t.year&&e.month===t.month&&e.day===t.day,isSameMonth:(e,t)=>e.year===t.year&&e.month===t.month,isSameYear:(e,t)=>e.year===t.year,format:(e,t,a=s.defaultLocale,n)=>m.formatTokens(e,n,t,{monthNamesLong:h(a,"long"),monthNamesShort:h(a,"short"),weekdayNamesLong:m.weekdayNames(a,"long",c),weekdayNamesShort:m.weekdayNames(a,"short",c),weekday:N(e),locale:a}),parse:(e,t,a=s.defaultLocale)=>m.parseTokens(e,t,{monthNamesLong:h(a,"long"),monthNamesShort:h(a,"short")}),getMonthNames:(e=s.defaultLocale,t="long")=>h(e,t),getWeekdayNames:(e=s.defaultLocale,t="long")=>m.weekdayNames(e,t,c),getEraNames:(e=s.defaultLocale)=>m.eraNames(e,c),isRTL:(e=s.defaultLocale)=>m.directionForLocale(e)==="rtl"};exports.default=s;exports.hijri=s;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import {\n directionForLocale,\n eraNames,\n formatTokens,\n generateMonthGrid,\n monthNamesFromDates,\n parseTokens,\n weekdayNames,\n type CalendarAdapter,\n type CalendarDate,\n type CalendarGrid,\n type GridOptions,\n type MonthView,\n type NameWidth,\n type Time,\n type Weekday,\n} from \"@alydev/core\";\n\nconst CAL = \"islamic-umalqura\";\nconst DAY = 86_400_000;\n\nconst partsFmt = new Intl.DateTimeFormat(\"en-US-u-ca-islamic-umalqura-nu-latn\", {\n year: \"numeric\",\n month: \"numeric\",\n day: \"numeric\",\n timeZone: \"UTC\",\n});\n\n/** Hijri (Umm al-Qura) Y/M/D for a civil (Gregorian) Y/M/D. */\nfunction hijriFromCivil(gy: number, gm: number, gd: number): CalendarDate {\n const parts = partsFmt.formatToParts(new Date(Date.UTC(gy, gm - 1, gd, 12)));\n let year = 0;\n let month = 0;\n let day = 0;\n for (const p of parts) {\n if (p.type === \"year\") year = Number(p.value.replace(/[^0-9]/g, \"\"));\n else if (p.type === \"month\") month = Number(p.value);\n else if (p.type === \"day\") day = Number(p.value);\n }\n return { year, month, day };\n}\n\n/** Whole-day UTC day-number → civil Y/M/D. */\nfunction civilFromDayNumber(n: number): { y: number; m: number; d: number } {\n const dt = new Date(n * DAY);\n return { y: dt.getUTCFullYear(), m: dt.getUTCMonth() + 1, d: dt.getUTCDate() };\n}\n\nfunction hijriFromDayNumber(n: number): CalendarDate {\n const c = civilFromDayNumber(n);\n return hijriFromCivil(c.y, c.m, c.d);\n}\n\n/** Monotonic approximation of a Hijri date's day ordinal (for estimation only). */\nfunction ordinal(h: CalendarDate): number {\n return h.year * 354.36707 + (h.month - 1) * 29.53059 + h.day;\n}\n\nfunction cmp(a: CalendarDate, b: CalendarDate): number {\n return a.year - b.year || a.month - b.month || a.day - b.day;\n}\n\nconst ANCHOR_DN = Math.floor(Date.UTC(2000, 0, 1) / DAY);\nconst ANCHOR_H = hijriFromCivil(2000, 1, 1);\n\n/** Civil day-number of a Hijri date: estimate by ordinal, then exact fine-tune. */\nfunction toDayNumber(h: CalendarDate): number {\n let g = ANCHOR_DN + Math.round(ordinal(h) - ordinal(ANCHOR_H));\n for (let i = 0; i < 4; i++) {\n const diff = Math.round(ordinal(h) - ordinal(hijriFromDayNumber(g)));\n if (diff === 0) break;\n g += diff;\n }\n let guard = 0;\n while (cmp(hijriFromDayNumber(g), h) < 0 && guard++ < 60) g++;\n guard = 0;\n while (cmp(hijriFromDayNumber(g), h) > 0 && guard++ < 60) g--;\n return g;\n}\n\nfunction toLocalDate(h: CalendarDate, time?: Time): Date {\n const c = civilFromDayNumber(toDayNumber(h));\n return new Date(\n c.y,\n c.m - 1,\n c.d,\n time?.hour ?? 0,\n time?.minute ?? 0,\n time?.second ?? 0,\n time?.millisecond ?? 0,\n );\n}\n\nfunction daysInHijriMonth(year: number, month: number): number {\n const start = toDayNumber({ year, month, day: 1 });\n const next =\n month === 12\n ? toDayNumber({ year: year + 1, month: 1, day: 1 })\n : toDayNumber({ year, month: month + 1, day: 1 });\n return next - start;\n}\n\nfunction weekdayOf(h: CalendarDate): Weekday {\n const c = civilFromDayNumber(toDayNumber(h));\n return new Date(c.y, c.m - 1, c.d).getDay() as Weekday;\n}\n\nfunction monthNames(locale: string, width: NameWidth): string[] {\n const refYear = hijriFromCivil(new Date().getFullYear(), 6, 1).year;\n const dates = Array.from({ length: 12 }, (_, i) => {\n const c = civilFromDayNumber(toDayNumber({ year: refYear, month: i + 1, day: 15 }));\n return new Date(c.y, c.m - 1, c.d);\n });\n return monthNamesFromDates(dates, locale, width, CAL);\n}\n\n/**\n * The Hijri (Umm al-Qura / Islamic civil) calendar adapter. Conversion is backed\n * by the platform's ICU `islamic-umalqura` calendar, so no lookup tables ship in\n * the bundle. Stateless singleton; locale is always a parameter.\n */\nexport const hijri: CalendarAdapter = {\n id: \"hijri\",\n defaultLocale: \"ar-SA\",\n\n today: () => {\n const now = new Date();\n return hijriFromCivil(now.getFullYear(), now.getMonth() + 1, now.getDate());\n },\n toDate: (date, time) => toLocalDate(date, time),\n fromDate: (d) => hijriFromCivil(d.getFullYear(), d.getMonth() + 1, d.getDate()),\n\n addDays: (date, amount) => hijriFromDayNumber(toDayNumber(date) + amount),\n addMonths: (date, amount) => {\n const total = date.month - 1 + amount;\n const year = date.year + Math.floor(total / 12);\n const month = ((total % 12) + 12) % 12 + 1;\n return { year, month, day: Math.min(date.day, daysInHijriMonth(year, month)) };\n },\n addYears: (date, amount) => {\n const year = date.year + amount;\n return { year, month: date.month, day: Math.min(date.day, daysInHijriMonth(year, date.month)) };\n },\n\n startOfMonth: (date) => ({ year: date.year, month: date.month, day: 1 }),\n endOfMonth: (date) => ({\n year: date.year,\n month: date.month,\n day: daysInHijriMonth(date.year, date.month),\n }),\n daysInMonth: (year, month) => daysInHijriMonth(year, month),\n monthsInYear: () => 12,\n isLeapYear: (year) =>\n toDayNumber({ year: year + 1, month: 1, day: 1 }) - toDayNumber({ year, month: 1, day: 1 }) ===\n 355,\n\n getWeekday: (date) => weekdayOf(date),\n getMonthGrid: (view: MonthView, options: GridOptions): CalendarGrid =>\n generateMonthGrid(hijri, view, options),\n getYearRange: (around, size) => {\n const half = Math.floor(size / 2);\n return Array.from({ length: size }, (_, i) => around - half + i);\n },\n getWeek: (date, { weekStartsOn }) => {\n const firstOfYear: CalendarDate = { year: date.year, month: 1, day: 1 };\n const dayOfYear = toDayNumber(date) - toDayNumber(firstOfYear) + 1;\n const offset = (weekdayOf(firstOfYear) - weekStartsOn + 7) % 7;\n return Math.floor((dayOfYear + offset - 1) / 7) + 1;\n },\n\n compare: (a, b) => cmp(a, b),\n isSameDay: (a, b) => a.year === b.year && a.month === b.month && a.day === b.day,\n isSameMonth: (a, b) => a.year === b.year && a.month === b.month,\n isSameYear: (a, b) => a.year === b.year,\n\n format: (date, pattern, locale = hijri.defaultLocale, time) =>\n formatTokens(date, time, pattern, {\n monthNamesLong: monthNames(locale, \"long\"),\n monthNamesShort: monthNames(locale, \"short\"),\n weekdayNamesLong: weekdayNames(locale, \"long\", CAL),\n weekdayNamesShort: weekdayNames(locale, \"short\", CAL),\n weekday: weekdayOf(date),\n locale,\n }),\n parse: (input, pattern, locale = hijri.defaultLocale) =>\n parseTokens(input, pattern, {\n monthNamesLong: monthNames(locale, \"long\"),\n monthNamesShort: monthNames(locale, \"short\"),\n }),\n\n getMonthNames: (locale = hijri.defaultLocale, width = \"long\") => monthNames(locale, width),\n getWeekdayNames: (locale = hijri.defaultLocale, width = \"long\") =>\n weekdayNames(locale, width, CAL),\n getEraNames: (locale = hijri.defaultLocale) => eraNames(locale, CAL),\n isRTL: (locale = hijri.defaultLocale) => directionForLocale(locale) === \"rtl\",\n};\n\nexport default hijri;\n"],"names":["CAL","DAY","partsFmt","hijriFromCivil","gy","gm","gd","parts","year","month","day","p","civilFromDayNumber","n","dt","hijriFromDayNumber","c","ordinal","h","cmp","a","b","ANCHOR_DN","ANCHOR_H","toDayNumber","g","i","diff","guard","toLocalDate","time","daysInHijriMonth","start","weekdayOf","monthNames","locale","width","refYear","dates","_","monthNamesFromDates","hijri","now","date","d","amount","total","view","options","generateMonthGrid","around","size","half","weekStartsOn","firstOfYear","dayOfYear","offset","pattern","formatTokens","weekdayNames","input","parseTokens","eraNames","directionForLocale"],"mappings":"4IAkBMA,EAAM,mBACNC,EAAM,MAENC,EAAW,IAAI,KAAK,eAAe,sCAAuC,CAC9E,KAAM,UACN,MAAO,UACP,IAAK,UACL,SAAU,KACZ,CAAC,EAGD,SAASC,EAAeC,EAAYC,EAAYC,EAA0B,CACxE,MAAMC,EAAQL,EAAS,cAAc,IAAI,KAAK,KAAK,IAAIE,EAAIC,EAAK,EAAGC,EAAI,EAAE,CAAC,CAAC,EAC3E,IAAIE,EAAO,EACPC,EAAQ,EACRC,EAAM,EACV,UAAWC,KAAKJ,EACVI,EAAE,OAAS,OAAQH,EAAO,OAAOG,EAAE,MAAM,QAAQ,UAAW,EAAE,CAAC,EAC1DA,EAAE,OAAS,QAASF,EAAQ,OAAOE,EAAE,KAAK,EAC1CA,EAAE,OAAS,QAAOD,EAAM,OAAOC,EAAE,KAAK,GAEjD,MAAO,CAAE,KAAAH,EAAM,MAAAC,EAAO,IAAAC,CAAA,CACxB,CAGA,SAASE,EAAmBC,EAAgD,CAC1E,MAAMC,EAAK,IAAI,KAAKD,EAAIZ,CAAG,EAC3B,MAAO,CAAE,EAAGa,EAAG,eAAA,EAAkB,EAAGA,EAAG,YAAA,EAAgB,EAAG,EAAGA,EAAG,YAAW,CAC7E,CAEA,SAASC,EAAmBF,EAAyB,CACnD,MAAMG,EAAIJ,EAAmBC,CAAC,EAC9B,OAAOV,EAAea,EAAE,EAAGA,EAAE,EAAGA,EAAE,CAAC,CACrC,CAGA,SAASC,EAAQC,EAAyB,CACxC,OAAOA,EAAE,KAAO,WAAaA,EAAE,MAAQ,GAAK,SAAWA,EAAE,GAC3D,CAEA,SAASC,EAAIC,EAAiBC,EAAyB,CACrD,OAA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D,EAAE,OAASC,EAAE,MAAQD,EAAE,QAAUC,EAAE,OAASD,EAAE,MAAQC,EAAE,IAC7E,YAAa,CAACD,EAAGC,IAAMD,EAAE,OAASC,EAAE,MAAQD,EAAE,QAAUC,EAAE,MAC1D,WAAY,CAACD,EAAGC,IAAMD,EAAE,OAASC,EAAE,KAEnC,OAAQ,CAACsB,EAAMc,EAAStB,EAASM,EAAM,cAAeX,IACpD4B,EAAAA,aAAaf,EAAMb,EAAM2B,EAAS,CAChC,eAAgBvB,EAAWC,EAAQ,MAAM,EACzC,gBAAiBD,EAAWC,EAAQ,OAAO,EAC3C,iBAAkBwB,EAAAA,aAAaxB,EAAQ,OAAQnC,CAAG,EAClD,kBAAmB2D,EAAAA,aAAaxB,EAAQ,QAASnC,CAAG,EACpD,QAASiC,EAAUU,CAAI,EACvB,OAAAR,CAAA,CACD,EACH,MAAO,CAACyB,EAAOH,EAAStB,EAASM,EAAM,gBACrCoB,EAAAA,YAAYD,EAAOH,EAAS,CAC1B,eAAgBvB,EAAWC,EAAQ,MAAM,EACzC,gBAAiBD,EAAWC,EAAQ,OAAO,CAAA,CAC5C,EAEH,cAAe,CAACA,EAASM,EAAM,cAAeL,EAAQ,SAAWF,EAAWC,EAAQC,CAAK,EACzF,gBAAiB,CAACD,EAASM,EAAM,cAAeL,EAAQ,SACtDuB,eAAaxB,EAAQC,EAAOpC,CAAG,EACjC,YAAa,CAACmC,EAASM,EAAM,gBAAkBqB,EAAAA,SAAS3B,EAAQnC,CAAG,EACnE,MAAO,CAACmC,EAASM,EAAM,gBAAkBsB,EAAAA,mBAAmB5B,CAAM,IAAM,KAC1E"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CalendarAdapter } from '../packages/core/src/index.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The Hijri (Umm al-Qura / Islamic civil) calendar adapter. Conversion is backed
|
|
4
|
+
* by the platform's ICU `islamic-umalqura` calendar, so no lookup tables ship in
|
|
5
|
+
* the bundle. Stateless singleton; locale is always a parameter.
|
|
6
|
+
*/
|
|
7
|
+
export declare const hijri: CalendarAdapter;
|
|
8
|
+
export default hijri;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,eAAe,EAQrB,MAAM,cAAc,CAAC;AAoGtB;;;;GAIG;AACH,eAAO,MAAM,KAAK,EAAE,eA0EnB,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { directionForLocale as L, eraNames as p, weekdayNames as D, parseTokens as Y, formatTokens as k, generateMonthGrid as F, monthNamesFromDates as T } from "@alydev/core";
|
|
2
|
+
const u = "islamic-umalqura", w = 864e5, C = new Intl.DateTimeFormat("en-US-u-ca-islamic-umalqura-nu-latn", {
|
|
3
|
+
year: "numeric",
|
|
4
|
+
month: "numeric",
|
|
5
|
+
day: "numeric",
|
|
6
|
+
timeZone: "UTC"
|
|
7
|
+
});
|
|
8
|
+
function c(e, t, a) {
|
|
9
|
+
const n = C.formatToParts(new Date(Date.UTC(e, t - 1, a, 12)));
|
|
10
|
+
let o = 0, i = 0, s = 0;
|
|
11
|
+
for (const y of n)
|
|
12
|
+
y.type === "year" ? o = Number(y.value.replace(/[^0-9]/g, "")) : y.type === "month" ? i = Number(y.value) : y.type === "day" && (s = Number(y.value));
|
|
13
|
+
return { year: o, month: i, day: s };
|
|
14
|
+
}
|
|
15
|
+
function g(e) {
|
|
16
|
+
const t = new Date(e * w);
|
|
17
|
+
return { y: t.getUTCFullYear(), m: t.getUTCMonth() + 1, d: t.getUTCDate() };
|
|
18
|
+
}
|
|
19
|
+
function f(e) {
|
|
20
|
+
const t = g(e);
|
|
21
|
+
return c(t.y, t.m, t.d);
|
|
22
|
+
}
|
|
23
|
+
function l(e) {
|
|
24
|
+
return e.year * 354.36707 + (e.month - 1) * 29.53059 + e.day;
|
|
25
|
+
}
|
|
26
|
+
function M(e, t) {
|
|
27
|
+
return e.year - t.year || e.month - t.month || e.day - t.day;
|
|
28
|
+
}
|
|
29
|
+
const S = Math.floor(Date.UTC(2e3, 0, 1) / w), A = c(2e3, 1, 1);
|
|
30
|
+
function r(e) {
|
|
31
|
+
let t = S + Math.round(l(e) - l(A));
|
|
32
|
+
for (let n = 0; n < 4; n++) {
|
|
33
|
+
const o = Math.round(l(e) - l(f(t)));
|
|
34
|
+
if (o === 0) break;
|
|
35
|
+
t += o;
|
|
36
|
+
}
|
|
37
|
+
let a = 0;
|
|
38
|
+
for (; M(f(t), e) < 0 && a++ < 60; ) t++;
|
|
39
|
+
for (a = 0; M(f(t), e) > 0 && a++ < 60; ) t--;
|
|
40
|
+
return t;
|
|
41
|
+
}
|
|
42
|
+
function O(e, t) {
|
|
43
|
+
const a = g(r(e));
|
|
44
|
+
return new Date(
|
|
45
|
+
a.y,
|
|
46
|
+
a.m - 1,
|
|
47
|
+
a.d,
|
|
48
|
+
t?.hour ?? 0,
|
|
49
|
+
t?.minute ?? 0,
|
|
50
|
+
t?.second ?? 0,
|
|
51
|
+
t?.millisecond ?? 0
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
function d(e, t) {
|
|
55
|
+
const a = r({ year: e, month: t, day: 1 });
|
|
56
|
+
return r(t === 12 ? { year: e + 1, month: 1, day: 1 } : { year: e, month: t + 1, day: 1 }) - a;
|
|
57
|
+
}
|
|
58
|
+
function N(e) {
|
|
59
|
+
const t = g(r(e));
|
|
60
|
+
return new Date(t.y, t.m - 1, t.d).getDay();
|
|
61
|
+
}
|
|
62
|
+
function h(e, t) {
|
|
63
|
+
const a = c((/* @__PURE__ */ new Date()).getFullYear(), 6, 1).year, n = Array.from({ length: 12 }, (o, i) => {
|
|
64
|
+
const s = g(r({ year: a, month: i + 1, day: 15 }));
|
|
65
|
+
return new Date(s.y, s.m - 1, s.d);
|
|
66
|
+
});
|
|
67
|
+
return T(n, e, t, u);
|
|
68
|
+
}
|
|
69
|
+
const m = {
|
|
70
|
+
id: "hijri",
|
|
71
|
+
defaultLocale: "ar-SA",
|
|
72
|
+
today: () => {
|
|
73
|
+
const e = /* @__PURE__ */ new Date();
|
|
74
|
+
return c(e.getFullYear(), e.getMonth() + 1, e.getDate());
|
|
75
|
+
},
|
|
76
|
+
toDate: (e, t) => O(e, t),
|
|
77
|
+
fromDate: (e) => c(e.getFullYear(), e.getMonth() + 1, e.getDate()),
|
|
78
|
+
addDays: (e, t) => f(r(e) + t),
|
|
79
|
+
addMonths: (e, t) => {
|
|
80
|
+
const a = e.month - 1 + t, n = e.year + Math.floor(a / 12), o = (a % 12 + 12) % 12 + 1;
|
|
81
|
+
return { year: n, month: o, day: Math.min(e.day, d(n, o)) };
|
|
82
|
+
},
|
|
83
|
+
addYears: (e, t) => {
|
|
84
|
+
const a = e.year + t;
|
|
85
|
+
return { year: a, month: e.month, day: Math.min(e.day, d(a, e.month)) };
|
|
86
|
+
},
|
|
87
|
+
startOfMonth: (e) => ({ year: e.year, month: e.month, day: 1 }),
|
|
88
|
+
endOfMonth: (e) => ({
|
|
89
|
+
year: e.year,
|
|
90
|
+
month: e.month,
|
|
91
|
+
day: d(e.year, e.month)
|
|
92
|
+
}),
|
|
93
|
+
daysInMonth: (e, t) => d(e, t),
|
|
94
|
+
monthsInYear: () => 12,
|
|
95
|
+
isLeapYear: (e) => r({ year: e + 1, month: 1, day: 1 }) - r({ year: e, month: 1, day: 1 }) === 355,
|
|
96
|
+
getWeekday: (e) => N(e),
|
|
97
|
+
getMonthGrid: (e, t) => F(m, e, t),
|
|
98
|
+
getYearRange: (e, t) => {
|
|
99
|
+
const a = Math.floor(t / 2);
|
|
100
|
+
return Array.from({ length: t }, (n, o) => e - a + o);
|
|
101
|
+
},
|
|
102
|
+
getWeek: (e, { weekStartsOn: t }) => {
|
|
103
|
+
const a = { year: e.year, month: 1, day: 1 }, n = r(e) - r(a) + 1, o = (N(a) - t + 7) % 7;
|
|
104
|
+
return Math.floor((n + o - 1) / 7) + 1;
|
|
105
|
+
},
|
|
106
|
+
compare: (e, t) => M(e, t),
|
|
107
|
+
isSameDay: (e, t) => e.year === t.year && e.month === t.month && e.day === t.day,
|
|
108
|
+
isSameMonth: (e, t) => e.year === t.year && e.month === t.month,
|
|
109
|
+
isSameYear: (e, t) => e.year === t.year,
|
|
110
|
+
format: (e, t, a = m.defaultLocale, n) => k(e, n, t, {
|
|
111
|
+
monthNamesLong: h(a, "long"),
|
|
112
|
+
monthNamesShort: h(a, "short"),
|
|
113
|
+
weekdayNamesLong: D(a, "long", u),
|
|
114
|
+
weekdayNamesShort: D(a, "short", u),
|
|
115
|
+
weekday: N(e),
|
|
116
|
+
locale: a
|
|
117
|
+
}),
|
|
118
|
+
parse: (e, t, a = m.defaultLocale) => Y(e, t, {
|
|
119
|
+
monthNamesLong: h(a, "long"),
|
|
120
|
+
monthNamesShort: h(a, "short")
|
|
121
|
+
}),
|
|
122
|
+
getMonthNames: (e = m.defaultLocale, t = "long") => h(e, t),
|
|
123
|
+
getWeekdayNames: (e = m.defaultLocale, t = "long") => D(e, t, u),
|
|
124
|
+
getEraNames: (e = m.defaultLocale) => p(e, u),
|
|
125
|
+
isRTL: (e = m.defaultLocale) => L(e) === "rtl"
|
|
126
|
+
};
|
|
127
|
+
export {
|
|
128
|
+
m as default,
|
|
129
|
+
m as hijri
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import {\n directionForLocale,\n eraNames,\n formatTokens,\n generateMonthGrid,\n monthNamesFromDates,\n parseTokens,\n weekdayNames,\n type CalendarAdapter,\n type CalendarDate,\n type CalendarGrid,\n type GridOptions,\n type MonthView,\n type NameWidth,\n type Time,\n type Weekday,\n} from \"@alydev/core\";\n\nconst CAL = \"islamic-umalqura\";\nconst DAY = 86_400_000;\n\nconst partsFmt = new Intl.DateTimeFormat(\"en-US-u-ca-islamic-umalqura-nu-latn\", {\n year: \"numeric\",\n month: \"numeric\",\n day: \"numeric\",\n timeZone: \"UTC\",\n});\n\n/** Hijri (Umm al-Qura) Y/M/D for a civil (Gregorian) Y/M/D. */\nfunction hijriFromCivil(gy: number, gm: number, gd: number): CalendarDate {\n const parts = partsFmt.formatToParts(new Date(Date.UTC(gy, gm - 1, gd, 12)));\n let year = 0;\n let month = 0;\n let day = 0;\n for (const p of parts) {\n if (p.type === \"year\") year = Number(p.value.replace(/[^0-9]/g, \"\"));\n else if (p.type === \"month\") month = Number(p.value);\n else if (p.type === \"day\") day = Number(p.value);\n }\n return { year, month, day };\n}\n\n/** Whole-day UTC day-number → civil Y/M/D. */\nfunction civilFromDayNumber(n: number): { y: number; m: number; d: number } {\n const dt = new Date(n * DAY);\n return { y: dt.getUTCFullYear(), m: dt.getUTCMonth() + 1, d: dt.getUTCDate() };\n}\n\nfunction hijriFromDayNumber(n: number): CalendarDate {\n const c = civilFromDayNumber(n);\n return hijriFromCivil(c.y, c.m, c.d);\n}\n\n/** Monotonic approximation of a Hijri date's day ordinal (for estimation only). */\nfunction ordinal(h: CalendarDate): number {\n return h.year * 354.36707 + (h.month - 1) * 29.53059 + h.day;\n}\n\nfunction cmp(a: CalendarDate, b: CalendarDate): number {\n return a.year - b.year || a.month - b.month || a.day - b.day;\n}\n\nconst ANCHOR_DN = Math.floor(Date.UTC(2000, 0, 1) / DAY);\nconst ANCHOR_H = hijriFromCivil(2000, 1, 1);\n\n/** Civil day-number of a Hijri date: estimate by ordinal, then exact fine-tune. */\nfunction toDayNumber(h: CalendarDate): number {\n let g = ANCHOR_DN + Math.round(ordinal(h) - ordinal(ANCHOR_H));\n for (let i = 0; i < 4; i++) {\n const diff = Math.round(ordinal(h) - ordinal(hijriFromDayNumber(g)));\n if (diff === 0) break;\n g += diff;\n }\n let guard = 0;\n while (cmp(hijriFromDayNumber(g), h) < 0 && guard++ < 60) g++;\n guard = 0;\n while (cmp(hijriFromDayNumber(g), h) > 0 && guard++ < 60) g--;\n return g;\n}\n\nfunction toLocalDate(h: CalendarDate, time?: Time): Date {\n const c = civilFromDayNumber(toDayNumber(h));\n return new Date(\n c.y,\n c.m - 1,\n c.d,\n time?.hour ?? 0,\n time?.minute ?? 0,\n time?.second ?? 0,\n time?.millisecond ?? 0,\n );\n}\n\nfunction daysInHijriMonth(year: number, month: number): number {\n const start = toDayNumber({ year, month, day: 1 });\n const next =\n month === 12\n ? toDayNumber({ year: year + 1, month: 1, day: 1 })\n : toDayNumber({ year, month: month + 1, day: 1 });\n return next - start;\n}\n\nfunction weekdayOf(h: CalendarDate): Weekday {\n const c = civilFromDayNumber(toDayNumber(h));\n return new Date(c.y, c.m - 1, c.d).getDay() as Weekday;\n}\n\nfunction monthNames(locale: string, width: NameWidth): string[] {\n const refYear = hijriFromCivil(new Date().getFullYear(), 6, 1).year;\n const dates = Array.from({ length: 12 }, (_, i) => {\n const c = civilFromDayNumber(toDayNumber({ year: refYear, month: i + 1, day: 15 }));\n return new Date(c.y, c.m - 1, c.d);\n });\n return monthNamesFromDates(dates, locale, width, CAL);\n}\n\n/**\n * The Hijri (Umm al-Qura / Islamic civil) calendar adapter. Conversion is backed\n * by the platform's ICU `islamic-umalqura` calendar, so no lookup tables ship in\n * the bundle. Stateless singleton; locale is always a parameter.\n */\nexport const hijri: CalendarAdapter = {\n id: \"hijri\",\n defaultLocale: \"ar-SA\",\n\n today: () => {\n const now = new Date();\n return hijriFromCivil(now.getFullYear(), now.getMonth() + 1, now.getDate());\n },\n toDate: (date, time) => toLocalDate(date, time),\n fromDate: (d) => hijriFromCivil(d.getFullYear(), d.getMonth() + 1, d.getDate()),\n\n addDays: (date, amount) => hijriFromDayNumber(toDayNumber(date) + amount),\n addMonths: (date, amount) => {\n const total = date.month - 1 + amount;\n const year = date.year + Math.floor(total / 12);\n const month = ((total % 12) + 12) % 12 + 1;\n return { year, month, day: Math.min(date.day, daysInHijriMonth(year, month)) };\n },\n addYears: (date, amount) => {\n const year = date.year + amount;\n return { year, month: date.month, day: Math.min(date.day, daysInHijriMonth(year, date.month)) };\n },\n\n startOfMonth: (date) => ({ year: date.year, month: date.month, day: 1 }),\n endOfMonth: (date) => ({\n year: date.year,\n month: date.month,\n day: daysInHijriMonth(date.year, date.month),\n }),\n daysInMonth: (year, month) => daysInHijriMonth(year, month),\n monthsInYear: () => 12,\n isLeapYear: (year) =>\n toDayNumber({ year: year + 1, month: 1, day: 1 }) - toDayNumber({ year, month: 1, day: 1 }) ===\n 355,\n\n getWeekday: (date) => weekdayOf(date),\n getMonthGrid: (view: MonthView, options: GridOptions): CalendarGrid =>\n generateMonthGrid(hijri, view, options),\n getYearRange: (around, size) => {\n const half = Math.floor(size / 2);\n return Array.from({ length: size }, (_, i) => around - half + i);\n },\n getWeek: (date, { weekStartsOn }) => {\n const firstOfYear: CalendarDate = { year: date.year, month: 1, day: 1 };\n const dayOfYear = toDayNumber(date) - toDayNumber(firstOfYear) + 1;\n const offset = (weekdayOf(firstOfYear) - weekStartsOn + 7) % 7;\n return Math.floor((dayOfYear + offset - 1) / 7) + 1;\n },\n\n compare: (a, b) => cmp(a, b),\n isSameDay: (a, b) => a.year === b.year && a.month === b.month && a.day === b.day,\n isSameMonth: (a, b) => a.year === b.year && a.month === b.month,\n isSameYear: (a, b) => a.year === b.year,\n\n format: (date, pattern, locale = hijri.defaultLocale, time) =>\n formatTokens(date, time, pattern, {\n monthNamesLong: monthNames(locale, \"long\"),\n monthNamesShort: monthNames(locale, \"short\"),\n weekdayNamesLong: weekdayNames(locale, \"long\", CAL),\n weekdayNamesShort: weekdayNames(locale, \"short\", CAL),\n weekday: weekdayOf(date),\n locale,\n }),\n parse: (input, pattern, locale = hijri.defaultLocale) =>\n parseTokens(input, pattern, {\n monthNamesLong: monthNames(locale, \"long\"),\n monthNamesShort: monthNames(locale, \"short\"),\n }),\n\n getMonthNames: (locale = hijri.defaultLocale, width = \"long\") => monthNames(locale, width),\n getWeekdayNames: (locale = hijri.defaultLocale, width = \"long\") =>\n weekdayNames(locale, width, CAL),\n getEraNames: (locale = hijri.defaultLocale) => eraNames(locale, CAL),\n isRTL: (locale = hijri.defaultLocale) => directionForLocale(locale) === \"rtl\",\n};\n\nexport default hijri;\n"],"names":["CAL","DAY","partsFmt","hijriFromCivil","gy","gm","gd","parts","year","month","day","p","civilFromDayNumber","n","dt","hijriFromDayNumber","c","ordinal","h","cmp","a","b","ANCHOR_DN","ANCHOR_H","toDayNumber","g","i","diff","guard","toLocalDate","time","daysInHijriMonth","start","weekdayOf","monthNames","locale","width","refYear","dates","_","monthNamesFromDates","hijri","now","date","d","amount","total","view","options","generateMonthGrid","around","size","half","weekStartsOn","firstOfYear","dayOfYear","offset","pattern","formatTokens","weekdayNames","input","parseTokens","eraNames","directionForLocale"],"mappings":";AAkBA,MAAMA,IAAM,oBACNC,IAAM,OAENC,IAAW,IAAI,KAAK,eAAe,uCAAuC;AAAA,EAC9E,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,UAAU;AACZ,CAAC;AAGD,SAASC,EAAeC,GAAYC,GAAYC,GAA0B;AACxE,QAAMC,IAAQL,EAAS,cAAc,IAAI,KAAK,KAAK,IAAIE,GAAIC,IAAK,GAAGC,GAAI,EAAE,CAAC,CAAC;AAC3E,MAAIE,IAAO,GACPC,IAAQ,GACRC,IAAM;AACV,aAAWC,KAAKJ;AACd,IAAII,EAAE,SAAS,SAAQH,IAAO,OAAOG,EAAE,MAAM,QAAQ,WAAW,EAAE,CAAC,IAC1DA,EAAE,SAAS,UAASF,IAAQ,OAAOE,EAAE,KAAK,IAC1CA,EAAE,SAAS,UAAOD,IAAM,OAAOC,EAAE,KAAK;AAEjD,SAAO,EAAE,MAAAH,GAAM,OAAAC,GAAO,KAAAC,EAAA;AACxB;AAGA,SAASE,EAAmBC,GAAgD;AAC1E,QAAMC,IAAK,IAA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CACD;AAAA,EACH,OAAO,CAACyB,GAAOH,GAAStB,IAASM,EAAM,kBACrCoB,EAAYD,GAAOH,GAAS;AAAA,IAC1B,gBAAgBvB,EAAWC,GAAQ,MAAM;AAAA,IACzC,iBAAiBD,EAAWC,GAAQ,OAAO;AAAA,EAAA,CAC5C;AAAA,EAEH,eAAe,CAACA,IAASM,EAAM,eAAeL,IAAQ,WAAWF,EAAWC,GAAQC,CAAK;AAAA,EACzF,iBAAiB,CAACD,IAASM,EAAM,eAAeL,IAAQ,WACtDuB,EAAaxB,GAAQC,GAAOpC,CAAG;AAAA,EACjC,aAAa,CAACmC,IAASM,EAAM,kBAAkBqB,EAAS3B,GAAQnC,CAAG;AAAA,EACnE,OAAO,CAACmC,IAASM,EAAM,kBAAkBsB,EAAmB5B,CAAM,MAAM;AAC1E;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alydev/adapter-hijri",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Hijri (Umm al-Qura / Islamic) calendar adapter for Calix, backed by the platform ICU calendar.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/ualiyou/calix-datepicker.git",
|
|
11
|
+
"directory": "packages/adapters/hijri"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"calendar",
|
|
15
|
+
"datepicker",
|
|
16
|
+
"hijri",
|
|
17
|
+
"islamic",
|
|
18
|
+
"umalqura",
|
|
19
|
+
"calix"
|
|
20
|
+
],
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"module": "./dist/index.js",
|
|
26
|
+
"main": "./dist/index.cjs",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"require": "./dist/index.cjs"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@alydev/core": "2.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@vitest/coverage-v8": "^2.1.8",
|
|
40
|
+
"typescript": "^5.7.2",
|
|
41
|
+
"vite": "^6.0.5",
|
|
42
|
+
"vite-plugin-dts": "^4.4.0",
|
|
43
|
+
"vitest": "^2.1.8",
|
|
44
|
+
"@alydev/core": "2.0.0"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "vite build",
|
|
48
|
+
"dev": "vite build --watch",
|
|
49
|
+
"typecheck": "tsc --noEmit",
|
|
50
|
+
"lint": "eslint .",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"test:coverage": "vitest run --coverage",
|
|
53
|
+
"test:watch": "vitest",
|
|
54
|
+
"clean": "rimraf dist .turbo *.tsbuildinfo"
|
|
55
|
+
}
|
|
56
|
+
}
|