2 * Project IT Calendar - Day Interface & Type Definitions
3 * =======================================================
5 * This file contains TypeScript type definitions and interfaces
6 * used throughout the calendar application for type-safe date handling.
8 * IMPORTANT ARCHITECTURAL NOTE:
9 * -----------------------------
10 * This file contains ONLY type definitions - it produces NO JavaScript
11 * output when compiled. These types exist purely for TypeScript's
12 * static type checking and development-time tooling.
14 * Why separate type definitions?
15 * 1. Centralized type management: All date-related types in one place
16 * 2. Reusability: Multiple components can import the same types
17 * 3. Consistency: Ensures all components use the same type definitions
18 * 4. Documentation: Serves as living documentation of the data model
20 * ------------------------------------------------------------------
21 * TYPE SYSTEM IN CINNAMON/GJS CONTEXT:
22 * ------------------------------------------------------------------
23 * TypeScript types are STRIPPED at compile time when using:
24 * - Module: "None" in tsconfig.json
25 * - OutFile: Single-file bundling for Cinnamon applets
28 * - These interfaces EXIST only during development
29 * - They provide IDE autocompletion and error checking
30 * - They are REMOVED in production (no runtime overhead)
31 * - No global export needed (types don't exist at runtime)
33 * ------------------------------------------------------------------
34 * USAGE BY OTHER COMPONENTS:
35 * ------------------------------------------------------------------
36 * 1. CalendarLogic.ts (Primary Consumer):
37 * - Uses DayType enum to categorize days
38 * - Uses CalendarDay interface for structured date information
39 * - Provides type-safe holiday calculations
41 * 2. CalendarView.ts (Potential Consumer):
42 * - Could use these types for day cell rendering
43 * - Ensures consistency between logic and view layers
45 * 3. EventManager.ts (Potential Consumer):
46 * - Could use CalendarDay for event-date associations
48 * ------------------------------------------------------------------
49 * @author Arnold Schiller <calendar@projektit.de>
50 * @link https://github.com/ArnoldSchiller/calendar
51 * @link https://projektit.de/kalender
52 * @license GPL-3.0-or-later
55/* ================================================================
56 * DAY TYPE ENUMERATION
57 * ================================================================
59 * Defines all possible classifications for calendar days.
60 * Used for visual styling, behavior rules, and holiday logic.
62 * IMPORTANT: These values are used in:
63 * 1. CSS class selection (calendar-workday, calendar-holiday, etc.)
64 * 2. Business logic (is this a work day?)
65 * 3. UI rendering (different colors/styles per type)
70 * Standard working day (Monday-Friday, not a holiday).
71 * Default styling, no special behavior.
76 * Official statutory holiday.
77 * Banks/schools closed, legal holiday in the region.
78 * Styled with holiday colors, may have special behavior.
83 * Unofficial observance or traditional holiday.
84 * Normal work day but culturally significant.
85 * May have subtle visual indication.
90 * The current system date (today).
91 * Always highlighted regardless of day type.
92 * Special "today" styling applied.
97 * Saturday or Sunday (in most regions).
98 * Weekend styling applied, may affect business logic.
103 * Placeholder cell for calendar grid alignment.
104 * Days from previous/next month in current month view.
105 * Typically grayed out or visually distinct.
109/* ================================================================
110 * CALENDAR DAY INTERFACE
111 * ================================================================
113 * Complete structured representation of a single calendar day.
114 * Used when passing day information between components.
116 * DESIGN DECISION: Why not just use Date objects?
117 * - Dates alone don't carry classification information
118 * - Need to associate metadata (holiday names, day types)
119 * - Allows consistent data structure across the application
122export interface CalendarDay {
124 * The day number as displayed in the calendar (1-31).
125 * String type allows for special cases like "31*" or formatting.
130 * Full JavaScript Date object for this day.
131 * Used for calculations, comparisons, and time-based operations.
136 * Classification of this day (workday, holiday, weekend, etc.).
137 * Determines visual styling and business logic behavior.
142 * Human-readable description, typically holiday names.
143 * Examples: "New Year's Day", "Christmas", "German Unity Day"
144 * Empty string for normal days.
149 * Flag indicating if this is an official public holiday.
150 * true: Banks/schools closed, legal holiday
151 * false: Normal work day (even if it's an observance)
153 * Different from type='PUBLIC_HOLIDAY' because:
154 * - A day can be both TODAY and PUBLIC_HOLIDAY
155 * - This flag focuses on legal status, not classification
160/* ================================================================
161 * TYPE GUARD FUNCTIONS (Potential Future Enhancement)
162 * ================================================================
164 * These functions don't exist yet but show how types could be used:
166 * function isWorkDay(day: CalendarDay): boolean {
167 * return day.type === 'WORKDAY';
170 * function isHoliday(day: CalendarDay): boolean {
171 * return day.type === 'PUBLIC_HOLIDAY' || day.type === 'OBSERVANCE';
174 * function isWeekend(day: CalendarDay): boolean {
175 * return day.type === 'WEEKEND';
179/* ================================================================
181 * ================================================================
183 * NO GLOBAL EXPORT NEEDED:
184 * ------------------------
185 * Unlike other files in this project, we DO NOT use:
186 * (global as any).CalendarDay = CalendarDay;
188 * Reason: These are TypeScript-only type definitions that are
189 * completely removed during compilation. They don't exist at
190 * runtime in the GJS/Cinnamon environment.
192 * COMPILATION BEHAVIOR:
193 * ---------------------
194 * With tsconfig.json setting: "module": "none"
195 * - TypeScript interfaces and type aliases produce NO JavaScript
196 * - They exist only for type checking during development
197 * - No runtime code is generated for this file
199 * This is intentional and correct for type definition files.
202/* ================================================================
203 * EXAMPLE USAGE IN OTHER FILES
204 * ================================================================
206 * // In CalendarLogic.ts:
207 * import { CalendarDay, DayType } from './CalendarDay';
209 * function createCalendarDay(date: Date, holidayName: string): CalendarDay {
211 * dayNumber: date.getDate().toString(),
213 * type: holidayName ? 'PUBLIC_HOLIDAY' : 'WORKDAY',
214 * description: holidayName,
215 * isPublic: !!holidayName
219 * // In CalendarView.ts (if using TypeScript strictly):
220 * function renderDayCell(day: CalendarDay) {
221 * // TypeScript knows day has dayNumber, type, description, etc.
222 * applyStyle(day.type); // Type-safe access
223 * setText(day.dayNumber);
227/* ================================================================
228 * TODOs AND FUTURE ENHANCEMENTS
229 * ================================================================
231 * TODO: Add DayColor interface for theming support
232 * TODO: Add CalendarWeek type for week-based operations
233 * TODO: Add DateRange type for event span calculations
234 * TODO: Add type guard functions for runtime type checking
235 * TODO: Consider adding i18n keys to descriptions for translation