Skip to content

[Repo Assist] Add missing standard DateTime format specifiers for JS/TS and Python#4547

Open
github-actions[bot] wants to merge 6 commits intomainfrom
repo-assist/fix-datetime-format-specifiers-20260419-4a17b47961f0f467
Open

[Repo Assist] Add missing standard DateTime format specifiers for JS/TS and Python#4547
github-actions[bot] wants to merge 6 commits intomainfrom
repo-assist/fix-datetime-format-specifiers-20260419-4a17b47961f0f467

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 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:

Specifier Description Example
R/r RFC 1123 (always UTC) "Mon, 01 Sep 2014 16:37:02 GMT"
s Sortable ISO 8601, no timezone "2014-09-01T16:37:02"
u Universal sortable (always UTC) "2014-09-01 16:37:02Z"
F Full date/time (long date + long time) "Monday, 01 September 2014 16:37:02"
f Full date/time (long date + short time) "Monday, 01 September 2014 16:37"
G General date/time (short date + long time) "09/01/2014 16:37:02"
g General date/time (short date + short time) "09/01/2014 16:37"
M/m Month/day "September 1"
U Universal full (full format in UTC) "Monday, 01 September 2014 16:37:02"
Y/y Year/month "September 2014"

Previously, all of these threw "Unrecognized Date print format".

Changes

  • src/fable-library-ts/Date.ts: Added dateToString_R, dateToString_s, dateToString_u, dateToString_M, dateToString_Y helper functions. Updated both dateToStringWithKind and dateToStringWithOffset switch statements.
  • src/fable-library-py/fable_library/date.py: Added to_rfc1123_string, to_sortable_string, to_universal_sortable_string, to_month_day_string, to_year_month_string helpers. Updated date_to_string_with_kind and date_to_string_with_offset.
  • Tests: Added tests to tests/Js/Main/DateTimeTests.fs and tests/Python/TestDateTime.fs.

Notes

  • The R/r format uses the hardcoded shortDays/shortMonths arrays (locale-independent) rather than toUTCString() to ensure consistent output.
  • F, f, G, g are composites of the existing D/d/T/t helper functions.
  • For DateTimeOffset, R, u, and U convert to UTC as per .NET semantics.
  • No breaking changes — only new cases added to existing switch statements.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@8f2d44f5d624e31c4af7cdbd948c6f5eba875a85

…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>
dbrattli and others added 4 commits April 21, 2026 00:24
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>
@github-actions
Copy link
Copy Markdown
Contributor Author

Python Type Checking Results (Pyright)

Metric Value
Total errors 33
Files with errors 4
Excluded files 4
New errors ✅ No
Excluded files with errors (4 files)

These files have known type errors and are excluded from CI. Remove from pyrightconfig.ci.json as errors are fixed.

File Errors Status
temp/tests/Python/test_hash_set.py 18 Excluded
temp/tests/Python/test_applicative.py 12 Excluded
temp/tests/Python/test_nested_and_recursive_pattern.py 2 Excluded
temp/tests/Python/fable_modules/thoth_json_python/encode.py 1 Excluded

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>
@dbrattli dbrattli marked this pull request as ready for review April 21, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JavaScript / Python] Make a pass to implement missing pre-defined Date format

1 participant