fix: use locale-independent digits in temporal toString - #107
Merged
sshanks-kx merged 1 commit intoJul 31, 2026
Merged
Conversation
Month, Minute, Second and Timespan render their value via DecimalFormat with the JVM default locale, so under locales whose default digits are not 0-9 (Arabic, Persian, Bengali, ...) toString emitted non-ASCII digits, e.g. Month(22) -> "٢٠٠١-١١" instead of "2001-11". These are the canonical textual forms of kdb+ temporal atoms and must always use ASCII digits. Format i2()/i9() with DecimalFormatSymbols for Locale.ROOT so the output is identical regardless of the JVM default locale. Add a test that pins the digits under an Arabic-Indic locale.
sshanks-kx
approved these changes
Jul 31, 2026
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.
Summary
Month,Minute,SecondandTimespanrender their value throughDecimalFormatconstructed with the JVM default locale. Under locales whose default digits are not0–9(Arabic, Persian, Bengali, …)toString()emits non-ASCII digits, corrupting the canonical textual form of these kdb+ temporal atoms:Month(22)en-US2001-112001-11ar-EG٢٠٠١-١١2001-11fa-IR۲۰۰۱-۱۱2001-11bn-IN২০০১-১১2001-11The same affects
Minute(٠٠:٢٢),SecondandTimespan. This breaks logging, display, CSV export and any downstream parsing/comparison of these strings for users running under such a locale.Change
Format the helpers
i2()/i9()(used by all four temporaltoString()methods) withDecimalFormatSymbols.getInstance(Locale.ROOT), so the output is always ASCII regardless of the JVM default locale. Formatting semantics are otherwise unchanged.Testing
Added
testTemporalToStringLocaleIndependent, which pins the rendered digits under an Arabic-Indic locale (restoring the previous default afterwards). Full suite green (86 tests, no regressions).