[Repo Assist] feat(stdlib): add datetime module bindings#267
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
[Repo Assist] feat(stdlib): add datetime module bindings#267github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
Adds F# bindings for the Python datetime module, covering: - timedelta (duration with days/seconds/microseconds, total_seconds()) - date (year/month/day, isoformat, strftime, weekday, fromisoformat, replace) - time (hour/minute/second/microsecond, isoformat, strftime, fromisoformat) - datetime (full date+time, now, utcnow, fromisoformat, strptime, combine, timestamp, astimezone) - timezone (fixed-offset tzinfo, utc singleton) Each class has a separate static factory type (timedeltaStatic, dateStatic, timeStatic, datetimeStatic, timezoneStatic) for constructors and class methods. Int arguments use int($1) Emit wrappers to handle Fable's Int32 boxing. Adds 30 tests covering all bound classes and their main operations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 pull request from Repo Assist, an AI assistant for this repository.
Summary
Adds F# bindings for Python's
datetimemodule — one of the most-used modules in the stdlib and previously absent from Fable.Python.Changes
New file:
src/stdlib/Datetime.fsCovers the five main classes:
timedeltadays,seconds,microseconds,total_seconds()+ keyword-argument factorydateyear/month/day,isoformat(),strftime(),fromisoformat(),today(),fromtimestamp(),weekday(),replace()timehour/minute/second/microsecond,isoformat(),strftime(),fromisoformat()datetimenow(),utcnow(),fromisoformat(),strptime(),combine(),timestamp(),isoformat(),astimezone(),replaceDate(),replaceTime()timezoneutcsingletonNew file:
test/TestDatetime.fs— 30 tests covering all bound classes.Design Decisions
datetimeStatic) alongside the instance type (datetime). This mirrors the pattern inFunctools.fsandItertools.fsand keeps class methods separate from instance methods.Emittemplates wrap integer args withint(...)to handle Fable'sInt32boxing correctly.timedelta.Createandtime.Createuse[<NamedParams>]+[<Emit("$0($1...)")>]so callers can writetimedelta.Create(days = 2.0, hours = 3.0)idiomatically.datetime.isoformathas two overloads: no-arg (defaultTseparator) and asep: stringoverload via[<Emit>].replaceDateandreplaceTimeuse named-keyword Emits to avoid the complex optional-parameter combinatorial explosion of Python'sdatetime.replace(...).Trade-offs
tzinfo(abstract base class) is not bound since it is rarely used directly by consumers;timezonecovers the common use-case.datetime.replace()is split intoreplaceDateandreplaceTimehelpers rather than a single method with many optional args; this avoids a complex overload matrix while covering the most common use-cases.astimezoneacceptsobjfor thetzparameter to avoid a circular dependency withtimezone.CI will validate the build and all 30 new tests.
Note
🔒 Integrity filter blocked 10 items
The following items were blocked because they don't meet the GitHub integrity level.
list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter: