Make utc? case-insensitive#5
Open
carpentry-agent[bot] wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
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
Timezonestruct and lowercasing only the name while still checking delta and dst exactly is the right approach. - The fallback path when
tzisNothingstill 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-loweris 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 comparesTimezonestructs 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 thoughutc?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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves the TODO at the
utc?function: timezone name comparison is now case-insensitive usingString.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
TMstruct'sconst char *tm_zonefield). 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.