[Repo Assist] Add missing standard DateTime format specifiers for JS/TS and Python#4547
Open
github-actions[bot] wants to merge 6 commits intomainfrom
Open
Conversation
…ython Add support for these format specifiers in dateToStringWithKind and dateToStringWithOffset in both the TypeScript and Python runtime libraries: - R/r: RFC 1123 (e.g. "Mon, 01 Sep 2014 16:37:02 GMT") — always UTC - s: Sortable ISO 8601 (e.g. "2014-09-01T16:37:02") — no timezone - u: Universal sortable (e.g. "2014-09-01 16:37:02Z") — always UTC - F: Full date/time long (long date + long time) - f: Full date/time short (long date + short time) - G: General date/time long (short date + long time) - g: General date/time short (short date + short time) - M/m: Month/day (e.g. "September 1") - U: Universal full (full format in UTC) - Y/y: Year/month (e.g. "September 2014") Fixes #3976 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds JS and Python tests for the R (RFC 1123, UTC), u (universal sortable, UTC), and s (sortable, offset-local) format specifiers applied to DateTimeOffset, exercising the UTC conversion paths. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fable's Python mangler is case-insensitive for identifiers, so test names differing only by letter case collided when mangled. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
.NET's InvariantCulture uses "MMMM dd" for M (padded day, e.g. "September 01") and "yyyy MMMM" for Y (year first, e.g. "2014 September"), not the en-US variants the PR assumed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
Python Type Checking Results (Pyright)
Excluded files with errors (4 files)These files have known type errors and are excluded from CI. Remove from
|
DateTimeOffset is a datetime subclass with a custom __new__ signature; calling astimezone() on it triggers Python's internal reconstruction via type(self).__new__(...) which fails. Rebuild a plain datetime from the fields before converting to UTC. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
40 tasks
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.
🤖 This is an automated PR from Repo Assist.
Closes #3976
Summary
Adds support for the missing standard
DateTime.ToString()format specifiers in the JavaScript/TypeScript and Python runtime libraries:R/r"Mon, 01 Sep 2014 16:37:02 GMT"s"2014-09-01T16:37:02"u"2014-09-01 16:37:02Z"F"Monday, 01 September 2014 16:37:02"f"Monday, 01 September 2014 16:37"G"09/01/2014 16:37:02"g"09/01/2014 16:37"M/m"September 1"U"Monday, 01 September 2014 16:37:02"Y/y"September 2014"Previously, all of these threw
"Unrecognized Date print format".Changes
src/fable-library-ts/Date.ts: AddeddateToString_R,dateToString_s,dateToString_u,dateToString_M,dateToString_Yhelper functions. Updated bothdateToStringWithKindanddateToStringWithOffsetswitch statements.src/fable-library-py/fable_library/date.py: Addedto_rfc1123_string,to_sortable_string,to_universal_sortable_string,to_month_day_string,to_year_month_stringhelpers. Updateddate_to_string_with_kindanddate_to_string_with_offset.tests/Js/Main/DateTimeTests.fsandtests/Python/TestDateTime.fs.Notes
R/rformat uses the hardcodedshortDays/shortMonthsarrays (locale-independent) rather thantoUTCString()to ensure consistent output.F,f,G,gare composites of the existingD/d/T/thelper functions.DateTimeOffset,R,u, andUconvert to UTC as per .NET semantics.