The initWithString: method previously initialized the underlying JavaScript Date object using the local-time constructor (new Date(year, month, day)).
This caused the resulting absolute time to be corrupted by the host engine's local time zone configuration, effectively ignoring the explicit time zone offset provided in the initialization string.
The implementation was a fundamental violation of the canonical contract, as established by NSDate and to be followed by CPDate.
This commit refactors the parsing logic to use Date.UTC(), guaranteeing that the parsed components are evaluated independently of the host environment.
Additionally, it eliminates a redundant RegExp allocation during pattern matching and updates the API documentation to explicitly state that offset resolution is decoupled from both CPTimeZone and the host's local time rules.
The object returned by the host engine's Intl.supportedValuesOf("timeZone") lacks standard JavaScript Array prototype methods (e.g., slice, indexOf) when crossing the runtime bridge.
This previously caused exceptions in testKnownTimeZoneNamesUsesIntlWhenAvailable.
This commit resolves the exceptions by utilizing primitive JavaScript property access and zero-indexed iteration to construct a local array. This architecture safely isolates the class from bridge prototype limitations and CPArray dependencies.
Additionally, it explicitly appends the legacy aliases "GMT" and "UTC" during the manual array construction. Engines adhering to canonical IANA identifiers omit these aliases, which caused localTimeZone initialization to abort in UTC-bound CI environments.
Guaranteeing their presence resolves the null evaluation failure in testSecondsFromGMTForDate.
Intl.supportedValuesOf("timeZone") returns canonical IANA identifiers, omitting legacy aliases such as "GMT" and "UTC". This causes localTimeZone to evaluate to nil when the host engine operates in a UTC time zone, as abbreviationDictionary statically maps these aliases.
We explicitly append "GMT" and "UTC" to the dynamic knownTimeZoneNames array. This ensures invariant preservation for static dictionary lookups, guarantees successful object initialization across all UTC-bound environments, and resolves the evaluation in testSecondsFromGMTForDate on CI runners.
* Fix a GitHub CI failure on a UTC-configured runner. Name-based resolution previously found no candidate, and abbreviationForDate returned no value.
* Add a fallback mechanism that uses the system's current UTC offset when a name match fails.
* Ensure correct abbreviation resolution, regardless of the zone name string that the runtime reports.
* Update abbreviationForDate and _abbreviationForNameAndDate to read the short time zone name directly from Intl.DateTimeFormat(...).formatToParts(). This replaces regular expression parsing of date strings.
* Update knownTimeZoneNames to use Intl.supportedValuesOf('timeZone') to retrieve the complete IANA time zone set. The method falls back to the legacy 48-city list if Intl is unavailable.
* Replace duplicate regular expression logic in testInitWithNameRespectsDaylightSaving with a direct Intl call.
* Add pinning tests for the recently corrected offsets and the unchanged MSD value.
* Add a feature-detected test for the knownTimeZoneNames upgrade.
* Add two disabled tests to document unresolved gaps: non-English localizedName outputs and ambiguous reverse offset lookups.
* The full IANA-identity redesign as a separate task. Abbreviation-keyed lookups, colliding offsets, and English-only localizedName limitations remain unresolved in this interim fix.
* Correct timeDifferenceFromUTC values for MDT, WAT, NZDT, NZST, and WIT.
* Update MSK to the current constant UTC+3 offset. Russia abolished Daylight Saving Time in 2014.
* Leave MSD unchanged. Add an inline comment explaining that Moscow Summer Time no longer exists and assigning a new offset would fabricate data.
* Track future work to replace this static table with Intl-backed lookup from browsers’ internal values.
This future lookup will include a protocol seam for:
* runtimes without complete timezone data.
* developers who cannot tolerate non-current information from browser update latency or have other individual need.
Foundation/CPException.j: _CPRaiseRangeException and _CPRaiseInvalidArgumentException called METHOD_CALL_STRING(), undefined anywhere.
Every out-of-bounds CPArray access threw an
uncatchable JS ReferenceError instead of CPRangeException/
CPInvalidArgumentException.
Fixed to call the existing _CPMethodCallString(anObject, aSelector).
Tests/Foundation/CPArrayTest.j, CPMutableArrayTest.j: the defect
was invisible because test_objectAtIndex_ and test_objectsAtIndexes_
checked only that something was thrown, not what.
Added exception-identity checks, and fixed ConcreteArray/ConcreteMutableArray's
objectAtIndex: overrides, which threw a plain string and would have
failed the new checks.
Using ES6 destructuring in the `for...of` loop declaration
(`var [key, value] of _map.entries()`) causes the legacy
Objective-J compiler to emit "uninitialized global variable"
warnings for `key` and `value`.
This raises concerns about variable scoping and generates
unacceptable noise in the CI pipeline. To resolve the warnings,
the loop has been restructured to use standard array indexing
inside the loop body.
A TODO has been added to revert to ES6 destructuring once the
legacy compiler is retired.
- Create Foundation/_CPFoundationUtilities.j to house global low-level utilities.
- Implement CPIsNumeric as a concrete JavaScript function, preserving the exact legacy logic.
- Import _CPFoundationUtilities.j in the Foundation.j umbrella manifest.
- Replace _IS_NUMERIC macro calls at all call sites with CPIsNumeric().
Remove the pre-processor dependency on FORWARD_TO_CONCRETE_CLASS by inlining the class cluster instantiation routing logic across all designated initializers to support the new Go-based toolchain architecture.
Replace the unhygienic METHOD_CALL_STRING() C pre-processor macro
in CPException.j with a standard JavaScript helper function,
_CPMethodCallString().
Add a `// MARK: - Exception Utilities` navigation landmark.
This removes a legacy text-substitution dependency, enabling
single-pass AST generation for the platform-native compilation pipeline.
Key changes:
- Removed the `CAST_TO_INT` macro and replaced it with native ES6
`Math.trunc()` for float truncation.
- Replaced `var` with `let` for proper block scoping.
- Simplified boolean coercion in `boolValue` using the `!!` operator.
- Replaced the hostile `throw new Error` in `descriptionWithLocale:`
with a safe fallback to `self.toString()`.
- Added `FIXME` comments to explicitly document architectural
anti-patterns, including the global mutable state in `CPNumberUIDs`
and the unimplemented `decimalValue` method.
As part of the ongoing technical debt cleanup, this commit modernizes
CPTimer.j by removing its reliance on the C-preprocessor and updating
syntax to modern JavaScript standards.
Key changes:
- Replaced `#define CPTimerDefaultTimeInterval` with a native `const`.
- Replaced `var` with `const`/`let` for proper block scoping and immutability.
- Replaced the build-time `PLATFORM(DOM)` guard with a runtime
`typeof(window) !== 'undefined'` check, ensuring Foundation does not
depend on build-time platform flags.
- Added `FIXME` comments to explicitly document architectural anti-patterns:
- The invasive global override of `window.setTimeout` and `window.setInterval`.
- The use of `new Function` for string evaluation (CSP violation).
- The questionable exposure of `CPTimerDefaultTimeInterval` as a fallback.
While objc `#pragma mark` works in objj files, it requires a preprocessor to handle the directive.
// MARK: is the fully functional and correct Objective-J variant.
Resolves testKVCCountSetOperators failure in CPSetTest. The previous implementation lacked an override for valueForKey:, causing the runtime to fall back to the default CPObject behavior, which failed to recognize KVC collection operators (e.g., @count).
Delegating valueForKey: to valueForKeyPath: ensures that CPSet correctly routes KVC operations through the existing collection operator logic.
• Refactor @implementation _CPKVCSet and CPObject (CPSetKVO) from _CPSet.j to the tail of CPMutableSet.j.
• Fix legacy compiler parse failures by ensuring the CPMutableSet superclass symbol is fully resolved within the translation unit prior to proxy evaluation.
• Maintain strict DAG compliance across the modern toolchain pipeline topology.
• Embed explicit #pragma mark navigation landmarks and enforce Allman brace layout to improve human structural ergonomics.