@glatam/calendar-core 1.0.1 → 1.0.2
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/package.json +1 -1
- package/dist/index.d.ts +0 -21
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -90
- package/dist/index.js.map +0 -1
- package/dist/strategies/date-range.strategy.d.ts +0 -8
- package/dist/strategies/date-range.strategy.d.ts.map +0 -1
- package/dist/strategies/date-range.strategy.js +0 -32
- package/dist/strategies/date-range.strategy.js.map +0 -1
- package/dist/strategies/factory.d.ts +0 -10
- package/dist/strategies/factory.d.ts.map +0 -1
- package/dist/strategies/factory.js +0 -19
- package/dist/strategies/factory.js.map +0 -1
- package/dist/strategies/strategy.interface.d.ts +0 -15
- package/dist/strategies/strategy.interface.d.ts.map +0 -1
- package/dist/strategies/strategy.interface.js +0 -2
- package/dist/strategies/strategy.interface.js.map +0 -1
- package/dist/strategies/weekly.strategy.d.ts +0 -8
- package/dist/strategies/weekly.strategy.d.ts.map +0 -1
- package/dist/strategies/weekly.strategy.js +0 -36
- package/dist/strategies/weekly.strategy.js.map +0 -1
- package/dist/types.d.ts +0 -32
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils/date-utils.d.ts +0 -25
- package/dist/utils/date-utils.d.ts.map +0 -1
- package/dist/utils/date-utils.js +0 -53
- package/dist/utils/date-utils.js.map +0 -1
package/package.json
CHANGED
package/dist/index.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { BlockingRule, CalendarDay, TimeSlot } from './types.js';
|
|
2
|
-
export * from './types.js';
|
|
3
|
-
export * from './utils/date-utils.js';
|
|
4
|
-
export * from './strategies/strategy.interface.js';
|
|
5
|
-
export * from './strategies/weekly.strategy.js';
|
|
6
|
-
export * from './strategies/date-range.strategy.js';
|
|
7
|
-
export * from './strategies/factory.js';
|
|
8
|
-
/**
|
|
9
|
-
* Checks if a specific date or time slot is blocked and returns the matching rule.
|
|
10
|
-
*/
|
|
11
|
-
export declare function getBlockingRule(date: Date, slot: TimeSlot | undefined, rules: BlockingRule[]): BlockingRule | undefined;
|
|
12
|
-
export declare function isTimeBlocked(date: Date, slot: TimeSlot | undefined, rules: BlockingRule[]): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Generates an array of CalendarDay items representing a monthly calendar grid.
|
|
15
|
-
*/
|
|
16
|
-
export declare function generateMonthDays(year: number, month: number, rules: BlockingRule[], slotsPerDay?: TimeSlot[], startOfWeekDay?: number): CalendarDay[];
|
|
17
|
-
/**
|
|
18
|
-
* Generates an array of 7 CalendarDay items representing a single week view.
|
|
19
|
-
*/
|
|
20
|
-
export declare function generateWeekDays(referenceDate: Date, rules: BlockingRule[], slotsPerDay?: TimeSlot[], startOfWeekDay?: number): CalendarDay[];
|
|
21
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAqB,MAAM,YAAY,CAAC;AAIpF,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,yBAAyB,CAAC;AAExC;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,YAAY,GAAG,SAAS,CAUvH;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAEpG;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,YAAY,EAAE,EACrB,WAAW,GAAE,QAAQ,EAAO,EAC5B,cAAc,SAAI,GACjB,WAAW,EAAE,CAkCf;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,IAAI,EACnB,KAAK,EAAE,YAAY,EAAE,EACrB,WAAW,GAAE,QAAQ,EAAO,EAC5B,cAAc,SAAI,GACjB,WAAW,EAAE,CAgCf"}
|
package/dist/index.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { BlockingStrategyFactory } from './strategies/factory.js';
|
|
2
|
-
import { formatISODate, getStartOfWeek } from './utils/date-utils.js';
|
|
3
|
-
export * from './types.js';
|
|
4
|
-
export * from './utils/date-utils.js';
|
|
5
|
-
export * from './strategies/strategy.interface.js';
|
|
6
|
-
export * from './strategies/weekly.strategy.js';
|
|
7
|
-
export * from './strategies/date-range.strategy.js';
|
|
8
|
-
export * from './strategies/factory.js';
|
|
9
|
-
/**
|
|
10
|
-
* Checks if a specific date or time slot is blocked and returns the matching rule.
|
|
11
|
-
*/
|
|
12
|
-
export function getBlockingRule(date, slot, rules) {
|
|
13
|
-
for (const rule of rules) {
|
|
14
|
-
const strategy = BlockingStrategyFactory.getStrategy(rule.type);
|
|
15
|
-
if (slot) {
|
|
16
|
-
if (strategy.isSlotBlocked(date, slot, rule))
|
|
17
|
-
return rule;
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
if (strategy.isDateBlocked(date, rule))
|
|
21
|
-
return rule;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
export function isTimeBlocked(date, slot, rules) {
|
|
27
|
-
return !!getBlockingRule(date, slot, rules);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Generates an array of CalendarDay items representing a monthly calendar grid.
|
|
31
|
-
*/
|
|
32
|
-
export function generateMonthDays(year, month, rules, slotsPerDay = [], startOfWeekDay = 0) {
|
|
33
|
-
const firstDayOfMonth = new Date(year, month, 1);
|
|
34
|
-
const startGridDate = getStartOfWeek(firstDayOfMonth, startOfWeekDay);
|
|
35
|
-
const days = [];
|
|
36
|
-
const currentDate = new Date(startGridDate);
|
|
37
|
-
for (let i = 0; i < 42; i++) {
|
|
38
|
-
const dateCopy = new Date(currentDate);
|
|
39
|
-
const dateString = formatISODate(dateCopy);
|
|
40
|
-
const evaluatedSlots = slotsPerDay.map((slot) => {
|
|
41
|
-
const match = getBlockingRule(dateCopy, slot, rules);
|
|
42
|
-
return { ...slot, isBlocked: !!match, rule: match };
|
|
43
|
-
});
|
|
44
|
-
const dayRule = getBlockingRule(dateCopy, undefined, rules);
|
|
45
|
-
const isDayFullyBlocked = !!dayRule || (evaluatedSlots.length > 0 && evaluatedSlots.every((s) => s.isBlocked));
|
|
46
|
-
days.push({
|
|
47
|
-
dateString,
|
|
48
|
-
date: dateCopy,
|
|
49
|
-
isBlocked: isDayFullyBlocked,
|
|
50
|
-
rule: dayRule || (evaluatedSlots.length > 0 && evaluatedSlots.every((s) => s.isBlocked) ? evaluatedSlots[0].rule : undefined),
|
|
51
|
-
dayOfWeek: dateCopy.getDay(),
|
|
52
|
-
dayNumber: dateCopy.getDate(),
|
|
53
|
-
isCurrentMonth: dateCopy.getMonth() === month,
|
|
54
|
-
slots: evaluatedSlots,
|
|
55
|
-
});
|
|
56
|
-
currentDate.setDate(currentDate.getDate() + 1);
|
|
57
|
-
}
|
|
58
|
-
return days;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Generates an array of 7 CalendarDay items representing a single week view.
|
|
62
|
-
*/
|
|
63
|
-
export function generateWeekDays(referenceDate, rules, slotsPerDay = [], startOfWeekDay = 0) {
|
|
64
|
-
const startOfWeek = getStartOfWeek(referenceDate, startOfWeekDay);
|
|
65
|
-
const days = [];
|
|
66
|
-
const currentDate = new Date(startOfWeek);
|
|
67
|
-
for (let i = 0; i < 7; i++) {
|
|
68
|
-
const dateCopy = new Date(currentDate);
|
|
69
|
-
const dateString = formatISODate(dateCopy);
|
|
70
|
-
const evaluatedSlots = slotsPerDay.map((slot) => {
|
|
71
|
-
const match = getBlockingRule(dateCopy, slot, rules);
|
|
72
|
-
return { ...slot, isBlocked: !!match, rule: match };
|
|
73
|
-
});
|
|
74
|
-
const dayRule = getBlockingRule(dateCopy, undefined, rules);
|
|
75
|
-
const isDayFullyBlocked = !!dayRule || (evaluatedSlots.length > 0 && evaluatedSlots.every((s) => s.isBlocked));
|
|
76
|
-
days.push({
|
|
77
|
-
dateString,
|
|
78
|
-
date: dateCopy,
|
|
79
|
-
isBlocked: isDayFullyBlocked,
|
|
80
|
-
rule: dayRule || (evaluatedSlots.length > 0 && evaluatedSlots.every((s) => s.isBlocked) ? evaluatedSlots[0].rule : undefined),
|
|
81
|
-
dayOfWeek: dateCopy.getDay(),
|
|
82
|
-
dayNumber: dateCopy.getDate(),
|
|
83
|
-
isCurrentMonth: true,
|
|
84
|
-
slots: evaluatedSlots,
|
|
85
|
-
});
|
|
86
|
-
currentDate.setDate(currentDate.getDate() + 1);
|
|
87
|
-
}
|
|
88
|
-
return days;
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,yBAAyB,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,eAAe,CA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C,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;YAC7H,SAAS,EAAE,QAAQ,CAAC,MAAM,EAAE;YAC5B,SAAS,EAAE,QAAQ,CAAC,OAAO,EAAE;YAC7B,cAAc,EAAE,IAAI;YACpB,KAAK,EAAE,cAAc;SACtB,CAAC,CAAC;QAEH,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { BlockingRule, CalendarDay, TimeSlot, EvaluatedTimeSlot } from './types.js';\nimport { BlockingStrategyFactory } from './strategies/factory.js';\nimport { formatISODate, getStartOfWeek } from './utils/date-utils.js';\n\nexport * from './types.js';\nexport * from './utils/date-utils.js';\nexport * from './strategies/strategy.interface.js';\nexport * from './strategies/weekly.strategy.js';\nexport * from './strategies/date-range.strategy.js';\nexport * from './strategies/factory.js';\n\n/**\n * Checks if a specific date or time slot is blocked and returns the matching rule.\n */\nexport function getBlockingRule(date: Date, slot: TimeSlot | undefined, rules: BlockingRule[]): BlockingRule | undefined {\n for (const rule of rules) {\n const strategy = BlockingStrategyFactory.getStrategy(rule.type);\n if (slot) {\n if (strategy.isSlotBlocked(date, slot, rule)) return rule;\n } else {\n if (strategy.isDateBlocked(date, rule)) return rule;\n }\n }\n return undefined;\n}\n\nexport function isTimeBlocked(date: Date, slot: TimeSlot | undefined, rules: BlockingRule[]): boolean {\n return !!getBlockingRule(date, slot, rules);\n}\n\n/**\n * Generates an array of CalendarDay items representing a monthly calendar grid.\n */\nexport function generateMonthDays(\n year: number,\n month: number,\n rules: BlockingRule[],\n slotsPerDay: TimeSlot[] = [],\n startOfWeekDay = 0\n): CalendarDay[] {\n const firstDayOfMonth = new Date(year, month, 1);\n const startGridDate = getStartOfWeek(firstDayOfMonth, startOfWeekDay);\n\n const days: CalendarDay[] = [];\n const currentDate = new Date(startGridDate);\n\n for (let i = 0; i < 42; i++) {\n const dateCopy = new Date(currentDate);\n const dateString = formatISODate(dateCopy);\n\n const evaluatedSlots: EvaluatedTimeSlot[] = slotsPerDay.map((slot) => {\n const match = getBlockingRule(dateCopy, slot, rules);\n return { ...slot, isBlocked: !!match, rule: match };\n });\n\n const dayRule = getBlockingRule(dateCopy, undefined, rules);\n const isDayFullyBlocked = !!dayRule || (evaluatedSlots.length > 0 && evaluatedSlots.every((s) => s.isBlocked));\n\n days.push({\n dateString,\n date: dateCopy,\n isBlocked: isDayFullyBlocked,\n rule: dayRule || (evaluatedSlots.length > 0 && evaluatedSlots.every((s) => s.isBlocked) ? evaluatedSlots[0].rule : undefined),\n dayOfWeek: dateCopy.getDay(),\n dayNumber: dateCopy.getDate(),\n isCurrentMonth: dateCopy.getMonth() === month,\n slots: evaluatedSlots,\n });\n\n currentDate.setDate(currentDate.getDate() + 1);\n }\n\n return days;\n}\n\n/**\n * Generates an array of 7 CalendarDay items representing a single week view.\n */\nexport function generateWeekDays(\n referenceDate: Date,\n rules: BlockingRule[],\n slotsPerDay: TimeSlot[] = [],\n startOfWeekDay = 0\n): CalendarDay[] {\n const startOfWeek = getStartOfWeek(referenceDate, startOfWeekDay);\n const days: CalendarDay[] = [];\n const currentDate = new Date(startOfWeek);\n\n for (let i = 0; i < 7; i++) {\n const dateCopy = new Date(currentDate);\n const dateString = formatISODate(dateCopy);\n\n const evaluatedSlots: EvaluatedTimeSlot[] = slotsPerDay.map((slot) => {\n const match = getBlockingRule(dateCopy, slot, rules);\n return { ...slot, isBlocked: !!match, rule: match };\n });\n\n const dayRule = getBlockingRule(dateCopy, undefined, rules);\n const isDayFullyBlocked = !!dayRule || (evaluatedSlots.length > 0 && evaluatedSlots.every((s) => s.isBlocked));\n\n days.push({\n dateString,\n date: dateCopy,\n isBlocked: isDayFullyBlocked,\n rule: dayRule || (evaluatedSlots.length > 0 && evaluatedSlots.every((s) => s.isBlocked) ? evaluatedSlots[0].rule : undefined),\n dayOfWeek: dateCopy.getDay(),\n dayNumber: dateCopy.getDate(),\n isCurrentMonth: true,\n slots: evaluatedSlots,\n });\n\n currentDate.setDate(currentDate.getDate() + 1);\n }\n\n return days;\n}\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BlockingRule, TimeSlot } from '../types.js';
|
|
2
|
-
import { BlockingStrategy } from './strategy.interface.js';
|
|
3
|
-
export declare class DateRangeStrategy implements BlockingStrategy {
|
|
4
|
-
isDateBlocked(date: Date, rule: BlockingRule): boolean;
|
|
5
|
-
isSlotBlocked(date: Date, slot: TimeSlot, rule: BlockingRule): boolean;
|
|
6
|
-
private matchesDateRange;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=date-range.strategy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"date-range.strategy.d.ts","sourceRoot":"","sources":["../../src/strategies/date-range.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,qBAAa,iBAAkB,YAAW,gBAAgB;IACxD,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO;IAQtD,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO;IActE,OAAO,CAAC,gBAAgB;CAazB"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { formatISODate, isTimeOverlapping } from '../utils/date-utils.js';
|
|
2
|
-
export class DateRangeStrategy {
|
|
3
|
-
isDateBlocked(date, rule) {
|
|
4
|
-
if (!this.matchesDateRange(date, rule)) {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
// If no slots are defined, the entire day is blocked.
|
|
8
|
-
return !rule.slots || rule.slots.length === 0;
|
|
9
|
-
}
|
|
10
|
-
isSlotBlocked(date, slot, rule) {
|
|
11
|
-
if (!this.matchesDateRange(date, rule)) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
// If no slots are defined, the entire day is blocked, so the slot is blocked.
|
|
15
|
-
if (!rule.slots || rule.slots.length === 0) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
// Check if the slot overlaps with any blocked slots in the rule
|
|
19
|
-
return rule.slots.some((blockedSlot) => isTimeOverlapping(slot, blockedSlot));
|
|
20
|
-
}
|
|
21
|
-
matchesDateRange(date, rule) {
|
|
22
|
-
const dateStr = formatISODate(date);
|
|
23
|
-
if (rule.startDate && dateStr < rule.startDate) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
if (rule.endDate && dateStr > rule.endDate) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=date-range.strategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"date-range.strategy.js","sourceRoot":"","sources":["../../src/strategies/date-range.strategy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE1E,MAAM,OAAO,iBAAiB;IAC5B,aAAa,CAAC,IAAU,EAAE,IAAkB;QAC1C,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;YACvC,OAAO,KAAK,CAAC;QACf,CAAC;QACD,sDAAsD;QACtD,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;IAChD,CAAC;IAED,aAAa,CAAC,IAAU,EAAE,IAAc,EAAE,IAAkB;QAC1D,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;YACvC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,8EAA8E;QAC9E,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3C,OAAO,IAAI,CAAC;QACd,CAAC;QAED,gEAAgE;QAChE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;IAChF,CAAC;IAEO,gBAAgB,CAAC,IAAU,EAAE,IAAkB;QACrD,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QAEpC,IAAI,IAAI,CAAC,SAAS,IAAI,OAAO,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YAC/C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YAC3C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { BlockingRule, TimeSlot } from '../types.js';\nimport { BlockingStrategy } from './strategy.interface.js';\nimport { formatISODate, isTimeOverlapping } from '../utils/date-utils.js';\n\nexport class DateRangeStrategy implements BlockingStrategy {\n isDateBlocked(date: Date, rule: BlockingRule): boolean {\n if (!this.matchesDateRange(date, rule)) {\n return false;\n }\n // If no slots are defined, the entire day is blocked.\n return !rule.slots || rule.slots.length === 0;\n }\n\n isSlotBlocked(date: Date, slot: TimeSlot, rule: BlockingRule): boolean {\n if (!this.matchesDateRange(date, rule)) {\n return false;\n }\n\n // If no slots are defined, the entire day is blocked, so the slot is blocked.\n if (!rule.slots || rule.slots.length === 0) {\n return true;\n }\n\n // Check if the slot overlaps with any blocked slots in the rule\n return rule.slots.some((blockedSlot) => isTimeOverlapping(slot, blockedSlot));\n }\n\n private matchesDateRange(date: Date, rule: BlockingRule): boolean {\n const dateStr = formatISODate(date);\n\n if (rule.startDate && dateStr < rule.startDate) {\n return false;\n }\n\n if (rule.endDate && dateStr > rule.endDate) {\n return false;\n }\n\n return true;\n }\n}\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BlockingRuleType } from '../types.js';
|
|
2
|
-
import { BlockingStrategy } from './strategy.interface.js';
|
|
3
|
-
export declare class BlockingStrategyFactory {
|
|
4
|
-
private static strategies;
|
|
5
|
-
/**
|
|
6
|
-
* Retrieves the strategy for a given rule type.
|
|
7
|
-
*/
|
|
8
|
-
static getStrategy(type: BlockingRuleType): BlockingStrategy;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/strategies/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAI3D,qBAAa,uBAAuB;IAClC,OAAO,CAAC,MAAM,CAAC,UAAU,CAGvB;IAEF;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB;CAO7D"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { WeeklyStrategy } from './weekly.strategy.js';
|
|
2
|
-
import { DateRangeStrategy } from './date-range.strategy.js';
|
|
3
|
-
export class BlockingStrategyFactory {
|
|
4
|
-
static { this.strategies = {
|
|
5
|
-
weekly: new WeeklyStrategy(),
|
|
6
|
-
'date-range': new DateRangeStrategy(),
|
|
7
|
-
}; }
|
|
8
|
-
/**
|
|
9
|
-
* Retrieves the strategy for a given rule type.
|
|
10
|
-
*/
|
|
11
|
-
static getStrategy(type) {
|
|
12
|
-
const strategy = this.strategies[type];
|
|
13
|
-
if (!strategy) {
|
|
14
|
-
throw new Error(`Estrategia de bloqueo no soportada: ${type}`);
|
|
15
|
-
}
|
|
16
|
-
return strategy;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=factory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/strategies/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,OAAO,uBAAuB;aACnB,eAAU,GAA+C;QACtE,MAAM,EAAE,IAAI,cAAc,EAAE;QAC5B,YAAY,EAAE,IAAI,iBAAiB,EAAE;KACtC,CAAC;IAEF;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,IAAsB;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,uCAAuC,IAAI,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC","sourcesContent":["import { BlockingRuleType } from '../types.js';\nimport { BlockingStrategy } from './strategy.interface.js';\nimport { WeeklyStrategy } from './weekly.strategy.js';\nimport { DateRangeStrategy } from './date-range.strategy.js';\n\nexport class BlockingStrategyFactory {\n private static strategies: Record<BlockingRuleType, BlockingStrategy> = {\n weekly: new WeeklyStrategy(),\n 'date-range': new DateRangeStrategy(),\n };\n\n /**\n * Retrieves the strategy for a given rule type.\n */\n static getStrategy(type: BlockingRuleType): BlockingStrategy {\n const strategy = this.strategies[type];\n if (!strategy) {\n throw new Error(`Estrategia de bloqueo no soportada: ${type}`);\n }\n return strategy;\n }\n}\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { BlockingRule, TimeSlot } from '../types.js';
|
|
2
|
-
export interface BlockingStrategy {
|
|
3
|
-
/**
|
|
4
|
-
* Evaluates if a given date is blocked by the rule.
|
|
5
|
-
* If the rule defines specific slots, a date is considered fully blocked
|
|
6
|
-
* only if the whole day is covered, or we check slot-by-slot.
|
|
7
|
-
* Here, isDateBlocked returns true if there is a day-wide block.
|
|
8
|
-
*/
|
|
9
|
-
isDateBlocked(date: Date, rule: BlockingRule): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Evaluates if a specific time slot on a given date is blocked by this rule.
|
|
12
|
-
*/
|
|
13
|
-
isSlotBlocked(date: Date, slot: TimeSlot, rule: BlockingRule): boolean;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=strategy.interface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strategy.interface.d.ts","sourceRoot":"","sources":["../../src/strategies/strategy.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC;IAEvD;;OAEG;IACH,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC;CACxE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strategy.interface.js","sourceRoot":"","sources":["../../src/strategies/strategy.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { BlockingRule, TimeSlot } from '../types.js';\n\nexport interface BlockingStrategy {\n /**\n * Evaluates if a given date is blocked by the rule.\n * If the rule defines specific slots, a date is considered fully blocked\n * only if the whole day is covered, or we check slot-by-slot.\n * Here, isDateBlocked returns true if there is a day-wide block.\n */\n isDateBlocked(date: Date, rule: BlockingRule): boolean;\n\n /**\n * Evaluates if a specific time slot on a given date is blocked by this rule.\n */\n isSlotBlocked(date: Date, slot: TimeSlot, rule: BlockingRule): boolean;\n}\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BlockingRule, TimeSlot } from '../types.js';
|
|
2
|
-
import { BlockingStrategy } from './strategy.interface.js';
|
|
3
|
-
export declare class WeeklyStrategy implements BlockingStrategy {
|
|
4
|
-
isDateBlocked(date: Date, rule: BlockingRule): boolean;
|
|
5
|
-
isSlotBlocked(date: Date, slot: TimeSlot, rule: BlockingRule): boolean;
|
|
6
|
-
private matchesDateAndDay;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=weekly.strategy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"weekly.strategy.d.ts","sourceRoot":"","sources":["../../src/strategies/weekly.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,qBAAa,cAAe,YAAW,gBAAgB;IACrD,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO;IAQtD,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO;IActE,OAAO,CAAC,iBAAiB;CAkB1B"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { formatISODate, isTimeOverlapping } from '../utils/date-utils.js';
|
|
2
|
-
export class WeeklyStrategy {
|
|
3
|
-
isDateBlocked(date, rule) {
|
|
4
|
-
if (!this.matchesDateAndDay(date, rule)) {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
// If no slots are defined, the entire day is blocked.
|
|
8
|
-
return !rule.slots || rule.slots.length === 0;
|
|
9
|
-
}
|
|
10
|
-
isSlotBlocked(date, slot, rule) {
|
|
11
|
-
if (!this.matchesDateAndDay(date, rule)) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
// If no slots are defined, the entire day is blocked, so the slot is blocked.
|
|
15
|
-
if (!rule.slots || rule.slots.length === 0) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
// Check if the slot overlaps with any blocked slots in the rule
|
|
19
|
-
return rule.slots.some((blockedSlot) => isTimeOverlapping(slot, blockedSlot));
|
|
20
|
-
}
|
|
21
|
-
matchesDateAndDay(date, rule) {
|
|
22
|
-
const dayOfWeek = date.getDay();
|
|
23
|
-
if (!rule.daysOfWeek || !rule.daysOfWeek.includes(dayOfWeek)) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
const dateStr = formatISODate(date);
|
|
27
|
-
if (rule.startDate && dateStr < rule.startDate) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
if (rule.endDate && dateStr > rule.endDate) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=weekly.strategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"weekly.strategy.js","sourceRoot":"","sources":["../../src/strategies/weekly.strategy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE1E,MAAM,OAAO,cAAc;IACzB,aAAa,CAAC,IAAU,EAAE,IAAkB;QAC1C,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;YACxC,OAAO,KAAK,CAAC;QACf,CAAC;QACD,sDAAsD;QACtD,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;IAChD,CAAC;IAED,aAAa,CAAC,IAAU,EAAE,IAAc,EAAE,IAAkB;QAC1D,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;YACxC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,8EAA8E;QAC9E,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3C,OAAO,IAAI,CAAC;QACd,CAAC;QAED,gEAAgE;QAChE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;IAChF,CAAC;IAEO,iBAAiB,CAAC,IAAU,EAAE,IAAkB;QACtD,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QAEpC,IAAI,IAAI,CAAC,SAAS,IAAI,OAAO,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YAC/C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YAC3C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { BlockingRule, TimeSlot } from '../types.js';\nimport { BlockingStrategy } from './strategy.interface.js';\nimport { formatISODate, isTimeOverlapping } from '../utils/date-utils.js';\n\nexport class WeeklyStrategy implements BlockingStrategy {\n isDateBlocked(date: Date, rule: BlockingRule): boolean {\n if (!this.matchesDateAndDay(date, rule)) {\n return false;\n }\n // If no slots are defined, the entire day is blocked.\n return !rule.slots || rule.slots.length === 0;\n }\n\n isSlotBlocked(date: Date, slot: TimeSlot, rule: BlockingRule): boolean {\n if (!this.matchesDateAndDay(date, rule)) {\n return false;\n }\n\n // If no slots are defined, the entire day is blocked, so the slot is blocked.\n if (!rule.slots || rule.slots.length === 0) {\n return true;\n }\n\n // Check if the slot overlaps with any blocked slots in the rule\n return rule.slots.some((blockedSlot) => isTimeOverlapping(slot, blockedSlot));\n }\n\n private matchesDateAndDay(date: Date, rule: BlockingRule): boolean {\n const dayOfWeek = date.getDay();\n if (!rule.daysOfWeek || !rule.daysOfWeek.includes(dayOfWeek)) {\n return false;\n }\n\n const dateStr = formatISODate(date);\n\n if (rule.startDate && dateStr < rule.startDate) {\n return false;\n }\n\n if (rule.endDate && dateStr > rule.endDate) {\n return false;\n }\n\n return true;\n }\n}\n"]}
|
package/dist/types.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export interface TimeSlot {
|
|
2
|
-
start: string;
|
|
3
|
-
end: string;
|
|
4
|
-
}
|
|
5
|
-
export type BlockingRuleType = 'weekly' | 'date-range';
|
|
6
|
-
export interface BlockingRule {
|
|
7
|
-
id: string;
|
|
8
|
-
type: BlockingRuleType;
|
|
9
|
-
startDate?: string;
|
|
10
|
-
endDate?: string;
|
|
11
|
-
daysOfWeek?: number[];
|
|
12
|
-
slots?: TimeSlot[];
|
|
13
|
-
description?: string;
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
}
|
|
16
|
-
export interface CalendarDay {
|
|
17
|
-
dateString: string;
|
|
18
|
-
date: Date;
|
|
19
|
-
isBlocked: boolean;
|
|
20
|
-
rule?: BlockingRule;
|
|
21
|
-
dayOfWeek: number;
|
|
22
|
-
dayNumber: number;
|
|
23
|
-
isCurrentMonth: boolean;
|
|
24
|
-
slots: EvaluatedTimeSlot[];
|
|
25
|
-
}
|
|
26
|
-
export interface EvaluatedTimeSlot {
|
|
27
|
-
start: string;
|
|
28
|
-
end: string;
|
|
29
|
-
isBlocked: boolean;
|
|
30
|
-
rule?: BlockingRule;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,YAAY,CAAC;AAEvD,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,gBAAgB,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,iBAAiB,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB"}
|
package/dist/types.js
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface TimeSlot {\n start: string;\n end: string;\n}\n\nexport type BlockingRuleType = 'weekly' | 'date-range';\n\nexport interface BlockingRule {\n id: string;\n type: BlockingRuleType;\n startDate?: string;\n endDate?: string;\n daysOfWeek?: number[];\n slots?: TimeSlot[];\n description?: string; // Descriptive title/notes for the task/block\n [key: string]: any; // Allow custom metadata (assignees, status, priority)\n}\n\nexport interface CalendarDay {\n dateString: string;\n date: Date;\n isBlocked: boolean;\n rule?: BlockingRule; // The rule blocking the whole day\n dayOfWeek: number;\n dayNumber: number;\n isCurrentMonth: boolean;\n slots: EvaluatedTimeSlot[];\n}\n\nexport interface EvaluatedTimeSlot {\n start: string;\n end: string;\n isBlocked: boolean;\n rule?: BlockingRule; // The rule that caused the block\n}\n"]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { TimeSlot } from '../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Parses an ISO date string (YYYY-MM-DD) into a local Date object.
|
|
4
|
-
* Prevents timezone shifting issues.
|
|
5
|
-
*/
|
|
6
|
-
export declare function parseISODate(dateStr: string): Date;
|
|
7
|
-
/**
|
|
8
|
-
* Formats a Date object to YYYY-MM-DD in the local timezone.
|
|
9
|
-
*/
|
|
10
|
-
export declare function formatISODate(date: Date): string;
|
|
11
|
-
/**
|
|
12
|
-
* Converts a time string "HH:MM" to minutes from midnight.
|
|
13
|
-
*/
|
|
14
|
-
export declare function timeToMinutes(timeStr: string): number;
|
|
15
|
-
/**
|
|
16
|
-
* Checks if two time slots overlap.
|
|
17
|
-
*/
|
|
18
|
-
export declare function isTimeOverlapping(slot1: TimeSlot, slot2: TimeSlot): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Gets the start of the week for a given date.
|
|
21
|
-
* @param date The date reference.
|
|
22
|
-
* @param startOfWeekDay The day the week starts (0 = Sunday, 1 = Monday). Default is 0.
|
|
23
|
-
*/
|
|
24
|
-
export declare function getStartOfWeek(date: Date, startOfWeekDay?: number): Date;
|
|
25
|
-
//# sourceMappingURL=date-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"date-utils.d.ts","sourceRoot":"","sources":["../../src/utils/date-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CASlD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAKhD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAO3E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,SAAI,GAAG,IAAI,CAMnE"}
|
package/dist/utils/date-utils.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses an ISO date string (YYYY-MM-DD) into a local Date object.
|
|
3
|
-
* Prevents timezone shifting issues.
|
|
4
|
-
*/
|
|
5
|
-
export function parseISODate(dateStr) {
|
|
6
|
-
const parts = dateStr.split('T')[0].split('-');
|
|
7
|
-
if (parts.length !== 3) {
|
|
8
|
-
return new Date(dateStr);
|
|
9
|
-
}
|
|
10
|
-
const year = parseInt(parts[0], 10);
|
|
11
|
-
const month = parseInt(parts[1], 10) - 1; // 0-indexed
|
|
12
|
-
const day = parseInt(parts[2], 10);
|
|
13
|
-
return new Date(year, month, day);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Formats a Date object to YYYY-MM-DD in the local timezone.
|
|
17
|
-
*/
|
|
18
|
-
export function formatISODate(date) {
|
|
19
|
-
const year = date.getFullYear();
|
|
20
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
21
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
22
|
-
return `${year}-${month}-${day}`;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Converts a time string "HH:MM" to minutes from midnight.
|
|
26
|
-
*/
|
|
27
|
-
export function timeToMinutes(timeStr) {
|
|
28
|
-
const [hours, minutes] = timeStr.split(':').map(Number);
|
|
29
|
-
return (hours || 0) * 60 + (minutes || 0);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Checks if two time slots overlap.
|
|
33
|
-
*/
|
|
34
|
-
export function isTimeOverlapping(slot1, slot2) {
|
|
35
|
-
const start1 = timeToMinutes(slot1.start);
|
|
36
|
-
const end1 = timeToMinutes(slot1.end);
|
|
37
|
-
const start2 = timeToMinutes(slot2.start);
|
|
38
|
-
const end2 = timeToMinutes(slot2.end);
|
|
39
|
-
return start1 < end2 && start2 < end1;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Gets the start of the week for a given date.
|
|
43
|
-
* @param date The date reference.
|
|
44
|
-
* @param startOfWeekDay The day the week starts (0 = Sunday, 1 = Monday). Default is 0.
|
|
45
|
-
*/
|
|
46
|
-
export function getStartOfWeek(date, startOfWeekDay = 0) {
|
|
47
|
-
const result = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
48
|
-
const day = result.getDay();
|
|
49
|
-
const diff = (day < startOfWeekDay ? 7 : 0) + day - startOfWeekDay;
|
|
50
|
-
result.setDate(result.getDate() - diff);
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=date-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"date-utils.js","sourceRoot":"","sources":["../../src/utils/date-utils.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,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AAC,CAAC;IAC1C,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEtC,OAAO,MAAM,GAAG,IAAI,IAAI,MAAM,GAAG,IAAI,CAAC;AACxC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAU,EAAE,cAAc,GAAG,CAAC;IAC3D,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7E,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,CAAC,GAAG,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,cAAc,CAAC;IACnE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { TimeSlot } from '../types.js';\n\n/**\n * Parses an ISO date string (YYYY-MM-DD) into a local Date object.\n * Prevents timezone shifting issues.\n */\nexport function parseISODate(dateStr: string): Date {\n const parts = dateStr.split('T')[0].split('-');\n if (parts.length !== 3) {\n return new Date(dateStr);\n }\n const year = parseInt(parts[0], 10);\n const month = parseInt(parts[1], 10) - 1; // 0-indexed\n const day = parseInt(parts[2], 10);\n return new Date(year, month, day);\n}\n\n/**\n * Formats a Date object to YYYY-MM-DD in the local timezone.\n */\nexport function formatISODate(date: Date): string {\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, '0');\n const day = String(date.getDate()).padStart(2, '0');\n return `${year}-${month}-${day}`;\n}\n\n/**\n * Converts a time string \"HH:MM\" to minutes from midnight.\n */\nexport function timeToMinutes(timeStr: string): number {\n const [hours, minutes] = timeStr.split(':').map(Number);\n return (hours || 0) * 60 + (minutes || 0);\n}\n\n/**\n * Checks if two time slots overlap.\n */\nexport function isTimeOverlapping(slot1: TimeSlot, slot2: TimeSlot): boolean {\n const start1 = timeToMinutes(slot1.start);\n const end1 = timeToMinutes(slot1.end);\n const start2 = timeToMinutes(slot2.start);\n const end2 = timeToMinutes(slot2.end);\n\n return start1 < end2 && start2 < end1;\n}\n\n/**\n * Gets the start of the week for a given date.\n * @param date The date reference.\n * @param startOfWeekDay The day the week starts (0 = Sunday, 1 = Monday). Default is 0.\n */\nexport function getStartOfWeek(date: Date, startOfWeekDay = 0): Date {\n const result = new Date(date.getFullYear(), date.getMonth(), date.getDate());\n const day = result.getDay();\n const diff = (day < startOfWeekDay ? 7 : 0) + day - startOfWeekDay;\n result.setDate(result.getDate() - diff);\n return result;\n}\n"]}
|