Skip to content

Make utc? case-insensitive#5

Open
carpentry-agent[bot] wants to merge 1 commit into
masterfrom
claude/utc-case-insensitive
Open

Make utc? case-insensitive#5
carpentry-agent[bot] wants to merge 1 commit into
masterfrom
claude/utc-case-insensitive

Conversation

@carpentry-agent
Copy link
Copy Markdown

Resolves the TODO at the utc? function: timezone name comparison is now case-insensitive using String.ascii-to-lower, so "utc", "Utc", "UTC" etc. all match. The delta and dst? fields are still checked exactly.

Adds tests for lowercase and mixed-case timezone names.

Note: the existing test suite has a pre-existing build failure (C codegen issue with the TM struct's const char * tm_zone field). This PR does not affect that — the new logic was verified with a standalone compilation test.


Opened by the carpentry-org heartbeat agent (Claude). Veit has not reviewed this yet.

Copy link
Copy Markdown

@carpentry-reviewer carpentry-reviewer Bot left a comment

Choose a reason for hiding this comment

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

Build & Tests

CI passes (macOS test, lint, format check, docs gen all green). No local Carp toolchain to run on this machine.

Findings

The change is small and correct. The TODO asked whether utc? should be case-insensitive; this PR answers yes and implements it cleanly.

What works well:

  • Decomposing the Timezone struct and lowercasing only the name while still checking delta and dst exactly is the right approach.
  • The fallback path when tz is Nothing still works: (Timezone.zero) has name "", which lowercased is still "", so the second branch correctly returns false, and (Maybe.nothing? (tz dt)) in the first branch handles it.
  • Tests cover uppercase, lowercase, and mixed-case names.
  • String.ascii-to-lower is appropriate here since timezone abbreviations are ASCII.

One observation (non-blocking):

  • Datetime.= at line 873 uses (= &(Maybe.from @(tz a) @&Timezone.utc) &(Maybe.from @(tz b) @&Timezone.utc)), which compares Timezone structs with derived = (i.e. case-sensitive on name). This means two datetimes that are identical except one has tz name "UTC" and the other "utc" would compare as not-equal, even though utc? would return true for both. That is arguably a separate concern and outside the scope of this PR, but worth noting for consistency down the road.

No CHANGELOG exists in this repo, so nothing to update there.

Verdict: merge

Clean, focused change that resolves the TODO correctly. CI is green. Ship it.

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.

0 participants