aboutsummaryrefslogtreecommitdiff
path: root/time/gameTime.ts
AgeCommit message (Collapse)AuthorFilesLines
2026-04-22Migrate remaining relative imports to @hollowdark/*; strip //-comments and ↵Bobby1-13/+8
doc references, JSDoc-only
2026-04-22Use relative imports for same-directory siblings; split utils into foldersBobby1-1/+1
Two related cleanups landed together because they touch the same pattern: 1. Intra-module imports now use relative paths rather than the module's own path alias. rng/seeded.ts imports from './derive', not 'rng/derive'; time/gameTime.ts from './calendar', not 'time/calendar'; the utils barrel from './result' etc. This matches rules/01-code-style.md: "Relative imports only for same-directory siblings." The alias form is reserved for imports *between* modules — how external callers refer to a module's public surface. (The TS language server in the IDE had trouble resolving the self- aliased form even though svelte-check accepted it; this change removes the ambiguity.) 2. utils/ is now folder-per-concept. Each utility owns a directory with its files broken up into small pieces: utils/result/ types, constructors, predicates, map, unwrap utils/assert/ assert, assert-never, assert-defined utils/equal/ deep utils/types/ brand, deep-readonly, element-of, json, non-empty-array utils/log/ log utils/index.ts re-exports from each subfolder via the barrel. External callers import from 'utils' unchanged; internal references are relative. One reason to prefer folders over flat files here is headroom — when a concept grows, new files sit alongside their siblings inside the concept's folder rather than crowding the utils/ root. No API changes. All 128 tests still green.
2026-04-22Implement GameTime and the 12-month calendarBobby1-0/+183
The Hollowdark calendar is 12 × 30-day months + a 5-day year-end festival = 365 days, with 7-day weeks (docs/01-world.md and the style bible). Months live in canonical order: spring 1 Thawing 2 Greening 3 Blossomtide summer 4 Highsun 5 Amberhaze 6 Harvestmark autumn 7 Firstfall 8 Stormturn 9 Ashfall winter 10 Rainfall 11 Hollowdark 12 Rimefrost festival 13 Year's End Festival (5 days) time/calendar.ts month names, season mapping, days-per-month, festival helpers time/gameTime.ts GameTime shape + arithmetic: makeGameTime, addDays / addWeeks / addMonths / addYears, daysBetween / weeksBetween, compare / isBefore / isAfter / isSameDay, dayOfWeek, dayOfYear, toAbsoluteDays, formatGameTime time/granularity.ts LifeStage + TickUnit mapping — one tick is a year in infancy, a season in childhood, a month in adolescence and old age, a week in adult life (docs/05-time-system.md, ARCHITECTURE.md §5) time/speed.ts Speed type: 'paused' | 'play' | 'fast' time/index.ts public re-exports Arithmetic is implemented by flattening GameTime to absolute-day integers (year × 365 + dayOfYear - 1) so addDays, daysBetween, and ordering are exact integer math. addMonths uses 13-month modular arithmetic and clamps the day into the festival's 5-day length on overflow. 59 unit tests in tests/unit/time/ cover constants, validation, arithmetic edge cases (Rimefrost 30 → Festival 1, Festival 5 → Thawing 1 of next year, day-clamping when landing in the festival), negative offsets, tickOfDay preservation, day-of-week stability, and life-stage boundaries.