Skip to content

FormatModule / docs rewrite#44

Merged
magmacomputing merged 2 commits into
mainfrom
feature/locale
Jun 14, 2026
Merged

FormatModule / docs rewrite#44
magmacomputing merged 2 commits into
mainfrom
feature/locale

Conversation

@magmacomputing

@magmacomputing magmacomputing commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

Release Notes - v3.1.1

  • New Features

    • Added formatting tokens {h12} (12-hour format) and {cal} (calendar identifier)
    • Introduced token modifiers: :raw, :ord, :upper, :lower, and :locale
    • Tempo.format() now accepts optional configuration parameter for runtime overrides
    • Automatic meridiem (AM/PM) insertion with 12-hour time formatting
  • Documentation

    • Updated examples and token reference with new tokens and modifiers
    • Added common formatting examples and numeric resolution guidance

@coderabbitai

coderabbitai Bot commented Jun 14, 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: 6f2d6ef6-9733-4d2b-9059-2ae8aa7500f3

📥 Commits

Reviewing files that changed from the base of the PR and between 12041d5 and ea10690.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (13)
  • packages/library/src/common/coercion.library.ts
  • packages/library/src/server/file.library.ts
  • packages/tempo/CHANGELOG.md
  • packages/tempo/doc/tempo.cookbook.md
  • packages/tempo/doc/tempo.format.md
  • packages/tempo/doc/tempo.registry.md
  • packages/tempo/package.json
  • packages/tempo/public/bundle.index.html
  • packages/tempo/src/module/module.format.ts
  • packages/tempo/src/tempo.version.ts
  • packages/tempo/test/discrete/locale.test.ts
  • packages/tempo/test/discrete/raw.test.ts
  • packages/tempo/test/discrete/test_upper.test.ts
✅ Files skipped from review due to trivial changes (5)
  • packages/tempo/src/tempo.version.ts
  • packages/tempo/test/discrete/locale.test.ts
  • packages/tempo/test/discrete/test_upper.test.ts
  • packages/tempo/test/discrete/raw.test.ts
  • packages/tempo/doc/tempo.cookbook.md
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/tempo/doc/tempo.registry.md
  • packages/tempo/public/bundle.index.html
  • packages/tempo/src/module/module.format.ts
  • packages/tempo/doc/tempo.format.md

📝 Walkthrough

Walkthrough

Tempo 3.1.1 adds an optional options argument to format() and Tempo.format() for per-call config overrides (e.g., locale), introduces {h12} and {cal} tokens, rewrites auto-meridiem injection, adds a :raw modifier, and extends the library's ifNumeric with safe-integer bigint range checks. Documentation, tests, and version metadata are updated throughout.

Changes

Library: Safe-integer bigint coercion

Layer / File(s) Summary
ifNumeric safe-integer range check and File.read bigint return type
packages/library/src/common/coercion.library.ts, packages/library/src/server/file.library.ts, packages/library/package.json
ifNumeric now converts integer-like and numeric string inputs via BigInt, returning bigint when outside Number.MIN_SAFE_INTEGER..MAX_SAFE_INTEGER and a Number otherwise. File.read return type widens to Promise<string | number | bigint>.

Tempo format() API enhancements and 3.1.1 release

Layer / File(s) Summary
format() options merging, new tokens, auto-meridiem rewrite, and :raw modifier
packages/tempo/src/module/module.format.ts, packages/tempo/src/tempo.class.ts
format() and Tempo.format() accept options?: any merged into intl, format, and registry config. New {h12} (12-hour) and {cal} (calendar ID) token branches are added. Auto-meridiem injection is rewritten to derive insertion position and modifiers from the hour token, skipping when :raw is present. A :raw modifier strips leading zeros via BigInt.
Test updates for h12, auto-meridiem, options, raw, cal, and locale
packages/tempo/test/discrete/format.test.ts, packages/tempo/test/engine/meridiem.test.ts, packages/tempo/test/instance/instance.format.test.ts, packages/tempo/test/issues/issue-fixes.test.ts, packages/tempo/test/discrete/test_upper.test.ts, packages/tempo/test/discrete/raw.test.ts, packages/tempo/test/discrete/locale.test.ts
format.test.ts adds options-override and rewrites auto-meridiem coverage. Existing tests migrate {HH} assertions to {h12}. New discrete suites cover h12:upper, :raw minute formatting, and locale token output.
Documentation: token table, modifiers, meridiem, examples, and changelog
packages/tempo/CHANGELOG.md, packages/tempo/doc/tempo.format.md, packages/tempo/doc/tempo.cookbook.md, packages/tempo/doc/tempo.registry.md, packages/tempo/README.md, packages/tempo/doc/installation.md
tempo.format.md is substantially revised with updated token reference table, new Token Modifiers subsection, rewritten Automatic Meridiem section, Numeric Resolution, and Common Formatting Examples. Cookbook, registry, README, and installation docs align to {h12} and {dd:ord}. CHANGELOG records 3.1.1 entries.
Version bumps to 3.1.1 and bundle example token update
package.json, packages/tempo/package.json, packages/library/package.json, packages/tempo/src/tempo.version.ts, packages/tempo/public/bundle.index.html
Monorepo root, library, and tempo package.json files bump from 3.1.0 to 3.1.1; tempo devDependency on library widens to *. TEMPO_VERSION constant is updated. Bundle HTML updates its import map URL and format token examples from {day} to {dd:raw}.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • magmacomputing/magma#19: Introduced the standalone format() function and its discrete module wiring, which is the same code path extended in this PR with the new options parameter.
  • magmacomputing/magma#43: Directly modifies module.format.ts token/modifier parsing and locale/localize behavior, the same file and logic extended here for {h12}, auto-meridiem, and :raw.

Poem

🐇 Hop hop! The clock chimes twelve with flair,
{h12} leaps from its burrow into the air.
:raw strips the zeros, neat and trim,
While options let locale dance on a whim.
The bigint is safe — no unsafe flight!
3.1.1 hops proudly into the light. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'FormatModule / docs rewrite' clearly and concisely summarizes the primary changes: updates to the FormatModule implementation and comprehensive documentation revisions across multiple files.
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/locale

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: 7

Caution

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

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

403-413: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

customDate sample output is now inconsistent with the {h12} template.

{h12}:{mi} is 12-hour output (with auto meridiem), but the example still shows 14:30 (24-hour).

✏️ Suggested doc fix
-console.log(t.format('customDate')); // "2026-06-03 14:30"
+console.log(t.format('customDate')); // "2026-06-03 02:30pm"

(If you want 24-hour output, switch back to {hh}:{mi}.)

🤖 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.cookbook.md` around lines 403 - 413, The custom date
format template in the Tempo cookbook example uses the h12 token (which produces
12-hour time format with automatic meridiem) but the expected output still shows
14:30, which is 24-hour format. This is inconsistent. Either update the format
template from customDate: '{yyyy}-{mm}-{dd} {h12}:{mi}' to use {hh} instead of
{h12} to match the 24-hour output shown, or update the expected output to
reflect the correct 12-hour formatted result that would include a meridiem
indicator (like 2:30 PM).
🧹 Nitpick comments (1)
packages/tempo/test/discrete/test_upper.ts (1)

1-3: ⚡ Quick win

Debug script committed under test directory.

This should be converted into a real describe/it assertion test (or removed) to avoid dead/noisy test assets.

🤖 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/test/discrete/test_upper.ts` around lines 1 - 3, The file
contains a debug script with a console.log statement instead of a proper unit
test. Convert this into a real test using describe/it blocks with assertion
statements. Replace the console.log statement that calls
t.format('{h12:upper}:{mi}') with an expect assertion that verifies the
formatted output matches the expected value, ensuring the test actually
validates the behavior rather than just printing debug output.
🤖 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/tempo/CHANGELOG.md`:
- Around line 9-17: The CHANGELOG.md entry for version 3.1.1 is incomplete and
missing documentation for several substantive format() feature additions. Add
entries to the "Added" section documenting the new {h12} token for 12-hour clock
output with automatic meridiem injection, the {cal} token for calendar system
resolution, and the :raw modifier for stripping leading zeros and suppressing
auto-meridiem. Additionally, add an entry to the "Changed" section documenting
the rewritten automatic meridiem injection logic that now derives modifiers from
the matched hour token. Use the suggested format from the review comment as a
reference for the content.

In `@packages/tempo/doc/tempo.format.md`:
- Line 112: The example output for the `{nano}` timestamp format in the
documentation table incorrectly includes a BigInt suffix `n` at the end of the
nanosecond value. Remove the trailing `n` character from the example output to
correctly represent what the runtime actually emits, which is a plain digit
string without the BigInt literal notation.

In `@packages/tempo/doc/tempo.registry.md`:
- Line 15: In the ISO format registry example comment, replace the `{h12}`
(12-hour hour format) with `{hh}` (24-hour hour format) to correctly represent
ISO-like formatting. The example should show a 24-hour time format, not 12-hour,
to maintain ISO semantics accuracy.

In `@packages/tempo/public/bundle.index.html`:
- Around line 240-243: The import map at line 229 specifies
`@magmacomputing/tempo` version 2, which does not support the {dd:raw} token
syntax being used in the console.log and resEl.textContent assignments at lines
240 and 243. Update the import map URL to reference `@magmacomputing/tempo`
version 3.1.1 or later (changing the version number in the CDN URL from `@2` to
`@3.1.1` or a compatible later version) to enable the raw token modifier syntax
required by the code.

In `@packages/tempo/src/module/module.format.ts`:
- Around line 104-118: The meridiem insertion logic only searches for literal
time tokens like {mi}, {ss}, {ms}, {us}, {ns}, {ff} without accounting for
optional modifiers (e.g., {mi:raw}, {ss:upper}). This causes the anchor point
calculation to miss or misplace the insertion point. Update the miIndex,
ssIndex, and subIndex searches to use regex patterns that match these tokens
with optional modifiers (similar to the existing pattern used for hIndex),
replacing lastIndexOf calls with search calls using patterns like /{mi[^}]*}/
for each respective token, ensuring the rightmost occurrence is found correctly.
- Around line 200-203: The 'raw' case in the format function loses precision for
large numeric values because parseInt converts via Number which has a
MAX_SAFE_INTEGER limit. Replace the parseInt conversion with BigInt to preserve
precision for large numbers like nanosecond values. Change the line to use
BigInt(String(res)).toString() instead of parseInt(String(res), 10).toString()
to ensure that large numeric strings are handled without precision loss.

In `@packages/tempo/test/discrete/debug.test.ts`:
- Around line 4-7: Replace the non-assertive debug code in these test files with
proper assertions. In packages/tempo/test/discrete/debug.test.ts (lines 4-7),
replace the console.log statement with an expect() assertion that validates the
format output for h12:upper and mi formatting. In
packages/tempo/test/discrete/raw.test.js (lines 1-3), test the Tempo :raw output
directly using expect() assertions rather than logging the result of parseInt.
In packages/tempo/test/discrete/locale.test.js (lines 2-3), use a fixed datetime
value and assert that the expected localized output matches the actual output
from Tempo. In packages/tempo/test/discrete/test_upper.ts (lines 1-3), either
convert the code into a proper test case using describe/it blocks with
assertions, or remove it entirely if it is scratch code.

---

Outside diff comments:
In `@packages/tempo/doc/tempo.cookbook.md`:
- Around line 403-413: The custom date format template in the Tempo cookbook
example uses the h12 token (which produces 12-hour time format with automatic
meridiem) but the expected output still shows 14:30, which is 24-hour format.
This is inconsistent. Either update the format template from customDate:
'{yyyy}-{mm}-{dd} {h12}:{mi}' to use {hh} instead of {h12} to match the 24-hour
output shown, or update the expected output to reflect the correct 12-hour
formatted result that would include a meridiem indicator (like 2:30 PM).

---

Nitpick comments:
In `@packages/tempo/test/discrete/test_upper.ts`:
- Around line 1-3: The file contains a debug script with a console.log statement
instead of a proper unit test. Convert this into a real test using describe/it
blocks with assertion statements. Replace the console.log statement that calls
t.format('{h12:upper}:{mi}') with an expect assertion that verifies the
formatted output matches the expected value, ensuring the test actually
validates the behavior rather than just printing debug output.
🪄 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: 63204d87-1ea9-4377-bb06-e36d44c2c7b0

📥 Commits

Reviewing files that changed from the base of the PR and between 3793f8b and 12041d5.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (20)
  • package.json
  • packages/library/package.json
  • packages/tempo/CHANGELOG.md
  • packages/tempo/README.md
  • packages/tempo/doc/installation.md
  • packages/tempo/doc/tempo.cookbook.md
  • packages/tempo/doc/tempo.format.md
  • packages/tempo/doc/tempo.registry.md
  • packages/tempo/package.json
  • packages/tempo/public/bundle.index.html
  • packages/tempo/src/module/module.format.ts
  • packages/tempo/src/tempo.class.ts
  • packages/tempo/test/discrete/debug.test.ts
  • packages/tempo/test/discrete/format.test.ts
  • packages/tempo/test/discrete/locale.test.js
  • packages/tempo/test/discrete/raw.test.js
  • packages/tempo/test/discrete/test_upper.ts
  • packages/tempo/test/engine/meridiem.test.ts
  • packages/tempo/test/instance/instance.format.test.ts
  • packages/tempo/test/issues/issue-fixes.test.ts

Comment thread packages/tempo/CHANGELOG.md
Comment thread packages/tempo/doc/tempo.format.md Outdated
Comment thread packages/tempo/doc/tempo.registry.md Outdated
Comment thread packages/tempo/public/bundle.index.html
Comment thread packages/tempo/src/module/module.format.ts
Comment thread packages/tempo/src/module/module.format.ts
Comment thread packages/tempo/test/discrete/debug.test.ts Outdated
@magmacomputing magmacomputing merged commit a206b0f into main Jun 14, 2026
2 checks passed
@magmacomputing magmacomputing deleted the feature/locale branch June 14, 2026 01:46
This was referenced Jun 15, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jun 25, 2026
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