Skip to content

weekOfYear#47

Merged
magmacomputing merged 3 commits into
mainfrom
feature/v3.2.2
Jun 18, 2026
Merged

weekOfYear#47
magmacomputing merged 3 commits into
mainfrom
feature/v3.2.2

Conversation

@magmacomputing

@magmacomputing magmacomputing commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added ISO week-of-year support via wy
    • Added compact 6-digit date tokens: dmy6, mdy6, ymd6 (2-digit years)
  • Changes

    • Renamed week token wwwy; ww remains deprecated
    • Added h24 token and refined h12/meridiem and ISO week token formatting
    • Improved how nested intl settings are merged
  • Bug Fixes

    • Hardened deep object merge/freeze against prototype pollution risks
  • Documentation

    • Updated token reference for the new/renamed tokens and {h12} vs {h24} guidance

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ec5c6db0-13bd-4ee5-99fd-7f45afddd845

📥 Commits

Reviewing files that changed from the base of the PR and between 02f3c1b and 27e4d73.

📒 Files selected for processing (3)
  • packages/library/src/common/object.library.ts
  • packages/library/src/common/utility.library.ts
  • packages/tempo/CHANGELOG.md
✅ Files skipped from review due to trivial changes (1)
  • packages/tempo/CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/library/src/common/object.library.ts

📝 Walkthrough

Walkthrough

Version 3.2.2 of the Tempo library renames the ISO week-of-year accessor from ww to wy across types, class getters, enums, and the format module; adds a getISOWeekOfYear polyfill implementing the nearest-Thursday ISO 8601 algorithm; removes uppercase format tokens; adds {h24} and short-year date tokens; introduces a deepMerge utility and hardens deepFreeze against prototype pollution; refactors the support module to consolidate IntlDefault; and bumps all package versions.

Changes

Tempo v3.2.2: ISO week rename and format token cleanup

Layer / File(s) Summary
getISOWeekOfYear polyfill
packages/library/src/common/international.library.ts
Adds isDefined to imports and exports a new getISOWeekOfYear function that short-circuits when both ISO week fields are already present, otherwise computes them via the nearest-Thursday algorithm on a Temporal.PlainDate.
deepMerge recursive merge utility
packages/library/src/common/object.library.ts
Introduces a deepMerge helper that recursively merges nested objects; when both values are objects it recurses, otherwise it overwrites. Skips __proto__, constructor, and prototype keys to prevent prototype pollution.
deepFreeze security hardening
packages/library/src/common/utility.library.ts
Updates deepFreeze to iterate over key/value entries and explicitly excludes __proto__, constructor, and prototype keys from recursion to prevent prototype-mutation DoS attacks.
Type definitions and Tempo class wy/ww refactor
packages/tempo/src/tempo.type.ts, packages/tempo/src/tempo.class.ts
Adds new wy type alias, marks existing ww as deprecated, imports getISOWeekOfYear, updates instance getters yw and wy to call the polyfill, and exports wy in the namespace type while mapping ww as a deprecated alias.
Enum and constant updates for wy token
packages/tempo/src/support/support.enum.ts
Updates DEFAULTS.FORMAT.yearWeek to use wy token, expands NumericPattern with new date patterns and replaces ww patterns with wy equivalents, and changes the ELEMENT token registry from ww to wy key.
Format module: deep merge, auto-meridiem narrowing, and token refinements
packages/tempo/src/module/module.format.ts
Adds deepMerge import and applies deep merging to intl configuration, narrows auto-meridiem to trigger only on {h12} (removes {HH} logic), consolidates yyww/yywy cases, revises hour token formatting to distinguish 24-hour and 12-hour modes, and adds new {dmy6}, {mdy6}, {ymd6} short-year date tokens.
Support module refactoring: IntlDefault and deep merging
packages/tempo/src/support/support.default.ts, packages/tempo/src/support/support.init.ts
Moves IntlDefault from a separate module into support.default.ts with explicit IntlOptions type, removes support.intl.ts entirely, and updates support.init.ts to use deepMerge for intl option merging.
Version bumps, changelog, and documentation
packages/tempo/src/tempo.version.ts, packages/tempo/package.json, package.json, packages/library/package.json, packages/tempo/CHANGELOG.md, packages/tempo/doc/tempo.format.md
Bumps all manifests and TEMPO_VERSION to 3.2.2, documents the 3.2.2 release with removed uppercase tokens, new short-year tokens, and security hardening, updates the format token reference to add {h24} and {yywy}, and revises the hour token explanation to emphasize explicit lowercase semantics.
Test suite updates for wy property and token changes
packages/tempo/test/core/static.test.ts, packages/tempo/test/discrete/format.test.ts, packages/tempo/test/engine/timezone_offset.test.ts, packages/tempo/test/instance/instance.format.test.ts
Adds wy to Tempo.properties test expectations, replaces the {HH} backward-compatibility test with an auto-meridiem test using non-time tokens, updates timezone offset test descriptions to {hh:mi} wording, and clarifies inline documentation from {HH} to {h12} terminology.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • magmacomputing/magma#44: Modifies the same auto-meridiem and hour token ({h12}/{mer}) formatting logic in module.format.ts that this PR further refines by narrowing meridiem injection to only {h12} and removing {HH} handling.

Poem

🐇 Hop hop, the tokens are neat,
No more {WW} or {HH} to greet!
wy leaps where ww once stood,
ISO weeks computed as they should.
Thursday's law guides the calendar right—
A rabbit's week, perfectly tight! 🗓️

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'weekOfYear' is vague and overly generic, failing to convey the full scope of meaningful changes in this comprehensive release. Consider a more descriptive title that captures the main changes, such as 'v3.2.2: Add ISO week utilities and refactor intl merging' or 'Refactor weekOfYear handling and add ISO week tokens'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/v3.2.2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/tempo/doc/tempo.format.md (1)

101-137: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Token table is still missing part of the new public surface.

Around Line 101, docs add {h24}, but the table should also prioritize {wy} (rename target) and include {dmy6}, {mdy6}, {ymd6} so docs match the formatter behavior shipped in this release.

💡 Suggested doc patch
-| `{ww}` | Zero-padded ISO Week of Year | `43` |
+| `{wy}` | Zero-padded ISO Week of Year | `43` |
@@
 | `{dmy}` | Compact Date (ddmmyyyy) | `24102026` |
 | `{mdy}` | Compact Date (mmddyyyy) | `10242026` |
 | `{ymd}` | Compact Date (yyyymmdd) | `20261024` |
+| `{dmy6}` | Compact Date (ddmmyy) | `241026` |
+| `{mdy6}` | Compact Date (mmddyy) | `102426` |
+| `{ymd6}` | Compact Date (yymmdd) | `261024` |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/tempo/doc/tempo.format.md` around lines 101 - 137, The token
documentation table starting around line 101 is incomplete and does not include
all tokens that are part of the public API. Add the missing `{wy}` token (which
should be prioritized in the table) and the three compact date tokens `{dmy6}`,
`{mdy6}`, and `{ymd6}` to the token table. Each token should have a descriptive
name, explanation of what it does, and a concrete example value consistent with
the existing token entries in the table so the documentation accurately reflects
the formatter behavior shipped in this release.
packages/tempo/src/module/module.format.ts (1)

169-180: ⚠️ Potential issue | 🟠 Major

Import and use getISOWeekOfYear helper for week tokens to prevent undefined output.

Week tokens (yw, yyww, yywy, ww, wy) directly access zdt.yearOfWeek and zdt.weekOfYear on lines 169, 170, and 179. This bypasses the getISOWeekOfYear helper (defined in international.library.ts) that provides a fallback ISO week calculation for environments where Temporal returns undefined week fields.

Fix: Use the ISO week helper
-import { formatDayPeriod, getDTF, getPR } from '`#library/international.library.js`';
+import { formatDayPeriod, getDTF, getPR, getISOWeekOfYear } from '`#library/international.library.js`';

 const result = template.replace(new RegExp(Match.formatBraces, 'g'), (_match: string, fullToken: string) => {
 	const [token, ...modifiers] = fullToken.split(':');
+	const isoWeek = getISOWeekOfYear(zdt);
 	let res: any;

 	switch (token) {
-		case 'yw': res = pad(zdt.yearOfWeek, 4); break;
-		case 'yyww': case 'yywy': res = pad(zdt.yearOfWeek, 4) + pad(zdt.weekOfYear); break;
+		case 'yw': res = pad(isoWeek.yearOfWeek, 4); break;
+		case 'yyww': case 'yywy': res = pad(isoWeek.yearOfWeek, 4) + pad(isoWeek.weekOfYear); break;
-		case 'ww': case 'wy': res = pad(zdt.weekOfYear); break;
+		case 'ww': case 'wy': res = pad(isoWeek.weekOfYear); break;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/tempo/src/module/module.format.ts` around lines 169 - 180, The week
token cases ('yw', 'yyww', 'yywy', 'ww', 'wy') are directly accessing
zdt.yearOfWeek and zdt.weekOfYear properties, which may return undefined in
certain environments. Replace these direct property accesses with calls to the
getISOWeekOfYear helper function from international.library.ts, which provides
proper fallback ISO week calculation. Ensure the helper is imported at the top
of the file and use it to safely retrieve both year of week and week of year
values for all affected token cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/library/src/common/international.library.ts`:
- Around line 155-166: The fallback ISO week computation uses calendar-dependent
properties (year, dayOfYear, dayOfWeek) on the PlainDate object, which will
produce incorrect results when the input has a non-ISO calendar. After creating
the pd constant from zdt, normalize it to the ISO 8601 calendar using the
withCalendar method before performing the shift and nearestThursday
calculations. This ensures that the year, dayOfYear, and dayOfWeek properties
reflect ISO 8601 values, making the subsequent yearOfWeek and weekOfYear
calculations correct regardless of the input calendar.

In `@packages/tempo/CHANGELOG.md`:
- Around line 9-13: The CHANGELOG entry for version 3.2.2 is incomplete and only
documents the removal of uppercase format tokens. Add documentation for the
additional breaking changes and new features in this release: add an entry
documenting the renaming of the `ww` token to `wy`, document the new short-year
tokens that were added, and include the new date format tokens `{dmy6}`,
`{mdy6}`, and `{ymd6}`. This information should be added as separate subsections
(such as "Changed" for the token rename and "Added" for new tokens) within the
3.2.2 release section to provide complete migration context for users upgrading
to this version.

In `@packages/tempo/src/support/support.enum.ts`:
- Line 87: The ELEMENT enum and elementKeys still reference the old `ww` token
while the yearWeek format definition at line 87 has been updated to use the new
`wy` token. Update all occurrences of `ww` in the ELEMENT enum entries (around
lines 217 and 221) to use `wy` instead to ensure consistency between the format
token surface and the public enum contract.

In `@packages/tempo/src/tempo.class.ts`:
- Around line 1376-1378: The removal of the `ww` getter property in favor of
`wy` is a breaking API change for a patch release. To maintain backward
compatibility, add back the `ww` property as a deprecated getter that returns
the same value as the new `wy` getter (calling getISOWeekOfYear and returning
weekOfYear). Additionally, ensure that the type alias `ww` is also exposed
alongside `wy` at line 1670 where the public API types are defined, so both
aliases remain available for existing consumers.

In `@packages/tempo/src/tempo.type.ts`:
- Line 148: The removal of the exported `ww` type alias on line 148 breaks
source-level compatibility for TypeScript consumers in a patch release. Add back
the `ww` type alias as a deprecated export that maps to the same IntRange type
as the new `wy` alias, maintaining backward compatibility while allowing
consumers to migrate to the new naming over time.

---

Outside diff comments:
In `@packages/tempo/doc/tempo.format.md`:
- Around line 101-137: The token documentation table starting around line 101 is
incomplete and does not include all tokens that are part of the public API. Add
the missing `{wy}` token (which should be prioritized in the table) and the
three compact date tokens `{dmy6}`, `{mdy6}`, and `{ymd6}` to the token table.
Each token should have a descriptive name, explanation of what it does, and a
concrete example value consistent with the existing token entries in the table
so the documentation accurately reflects the formatter behavior shipped in this
release.

In `@packages/tempo/src/module/module.format.ts`:
- Around line 169-180: The week token cases ('yw', 'yyww', 'yywy', 'ww', 'wy')
are directly accessing zdt.yearOfWeek and zdt.weekOfYear properties, which may
return undefined in certain environments. Replace these direct property accesses
with calls to the getISOWeekOfYear helper function from
international.library.ts, which provides proper fallback ISO week calculation.
Ensure the helper is imported at the top of the file and use it to safely
retrieve both year of week and week of year values for all affected token cases.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1c2bd382-95f8-4aa2-8b24-efaf61507563

📥 Commits

Reviewing files that changed from the base of the PR and between b0cd662 and 5501ebd.

📒 Files selected for processing (11)
  • package.json
  • packages/library/package.json
  • packages/library/src/common/international.library.ts
  • packages/tempo/CHANGELOG.md
  • packages/tempo/doc/tempo.format.md
  • packages/tempo/package.json
  • packages/tempo/src/module/module.format.ts
  • packages/tempo/src/support/support.enum.ts
  • packages/tempo/src/tempo.class.ts
  • packages/tempo/src/tempo.type.ts
  • packages/tempo/src/tempo.version.ts

Comment thread packages/library/src/common/international.library.ts Outdated
Comment thread packages/tempo/CHANGELOG.md
Comment thread packages/tempo/src/support/support.enum.ts
Comment thread packages/tempo/src/tempo.class.ts
Comment thread packages/tempo/src/tempo.type.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/library/src/common/object.library.ts`:
- Around line 115-121: The deepMerge function is vulnerable to prototype
pollution because it assigns values to arbitrary keys without validating them.
Before assigning a key-value pair in the forEach loop within deepMerge, add a
check to skip assignment for dangerous keys: __proto__, constructor, and
prototype. Only allow safe keys to be merged into the target object by adding a
guard condition that prevents these special property names from being assigned,
preventing potential prototype mutation attacks when untrusted data is passed to
the function.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 935a14fc-5029-406c-9faf-847caf2b086a

📥 Commits

Reviewing files that changed from the base of the PR and between 5501ebd and 02f3c1b.

📒 Files selected for processing (15)
  • packages/library/src/common/international.library.ts
  • packages/library/src/common/object.library.ts
  • packages/tempo/CHANGELOG.md
  • packages/tempo/doc/tempo.format.md
  • packages/tempo/src/module/module.format.ts
  • packages/tempo/src/support/support.default.ts
  • packages/tempo/src/support/support.enum.ts
  • packages/tempo/src/support/support.init.ts
  • packages/tempo/src/support/support.intl.ts
  • packages/tempo/src/tempo.class.ts
  • packages/tempo/src/tempo.type.ts
  • packages/tempo/test/core/static.test.ts
  • packages/tempo/test/discrete/format.test.ts
  • packages/tempo/test/engine/timezone_offset.test.ts
  • packages/tempo/test/instance/instance.format.test.ts
💤 Files with no reviewable changes (2)
  • packages/tempo/src/support/support.intl.ts
  • packages/tempo/test/discrete/format.test.ts
✅ Files skipped from review due to trivial changes (3)
  • packages/tempo/test/instance/instance.format.test.ts
  • packages/tempo/test/engine/timezone_offset.test.ts
  • packages/tempo/CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/tempo/src/tempo.class.ts
  • packages/tempo/src/module/module.format.ts
  • packages/library/src/common/international.library.ts

Comment thread packages/library/src/common/object.library.ts
@magmacomputing magmacomputing merged commit 6bdc4ee into main Jun 18, 2026
2 checks passed
@magmacomputing magmacomputing deleted the feature/v3.2.2 branch June 18, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant