[Python] Implement missing DateTimeOffset members, add DateOnly and TimeOnly#4477
Merged
[Python] Implement missing DateTimeOffset members, add DateOnly and TimeOnly#4477
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Python Type Checking Results (Pyright)
Excluded files with errors (4 files)These files have known type errors and are excluded from CI. Remove from
|
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use SupportsInt/SupportsFloat for Fable numeric type parameters - Add @overload for op_subtraction/subtract/__sub__ - Return int32 from compare/compare_to - Use Int64 constant for AddTicks divisor - Replace unsafe thisArg.Value with pattern matching Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add date_only.py: create, min/max, day/month/year, dayOfWeek, dayOfYear, addDays/Months/Years, toDateTime, toString, parse - Add time_only.py: create, fromTicks, fromTimeSpan, fromDateTime, add, addHours/Minutes, isBetween, toString, parse - Add DateTimeOffset: UnixEpoch, TotalOffsetMinutes, DateTimeOffset(DateOnly, TimeOnly, TimeSpan) constructor - Wire up dateOnly/timeOnly handlers in Python Replacements.fs - Add 21 new tests (10 DateOnly + 8 TimeOnly + 3 DateTimeOffset) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove datetime_offset.rs and .pyi stub (pure Python approach) - Return int32 from DateTimeOffset property accessors - Add TimeOnly property functions (hour, minute, second, millisecond, ticks) - Use SupportsFloat for TimeOnly add_hours/add_minutes - Route TimeOnly.MinValue through library call Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
38 tasks
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
|
@dbrattli While you're at it, perhaps also fix the |
- Fix misleading comment in _to_utc_ms - Remove unused _ticks_per_millisecond - Fix precision loss in ticks() using integer arithmetic - Add docstring to from_date_time clarifying representations - Add missing __all__ entries in time_only.py Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Refactor create() to use isinstance checks for TimeSpan offset detection, supporting all constructor arities: 7-arg (with offset), 8-arg (with ms and offset), and 9-arg (with ms, mc, and offset). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…int() Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dbrattli
added a commit
that referenced
this pull request
Apr 2, 2026
…eOnly Port the Python DateTimeOffset/DateOnly/TimeOnly work from #4477 to the Beam target. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 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.
Summary
DateTimeOffsetmembers for the Python target, closing Implement missing DateTimeOffset functionality for the Python target #4475DateOnlyandTimeOnlysupport (newdate_only.pyandtime_only.py)DateTimeOffsetequality/comparison to use UTC-normalized instants (.NET semantics)DateTimeOffset — new members
Constructors:
FromDate(DateTime),FromTicks(int64, TimeSpan),DateTimeOffset(DateOnly, TimeOnly, TimeSpan)Fields:
MaxValue,UnixEpochProperties:
UtcDateTime,LocalDateTime,Date,DayOfWeek,DayOfYear,TimeOfDay,Ticks,UtcTicks,TotalOffsetMinutesMethods:
Add,AddYears/Months/Days/Hours/Minutes/Seconds/Milliseconds/Ticks,ToUniversalTime,ToLocalTime,ToOffset,Subtract,Compare,CompareTo,EqualsExact,FromUnixTimeSeconds/Milliseconds,ToUnixTimeSeconds/MillisecondsOperators:
op_AdditionDateOnly — new
Constructors,
MinValue/MaxValue,Day/Month/Year,DayOfWeek,DayOfYear,AddDays/AddMonths/AddYears,ToDateTime,ToString,Parse/TryParse,FromDateTimeTimeOnly — new
Constructors,
MinValue,FromTicks,FromTimeSpan,FromDateTime,Hour/Minute/Second/Millisecond,Ticks,ToTimeSpan,Add,AddHours/AddMinutes,IsBetween,ToString,Parse/TryParse,op_SubtractionKey fixes
DateTimeOffsetequality/comparison routes todate_offsetmodule (UTC-normalized)FromUnixTimeSeconds/Millisecondscall properdate_offsetfunctionsfrom_date_time_offsetindate.pyreturns plaindatetime(notDateTimeOffsetsubclass)DateTimeOffset.__sub__/__add__overrides prevent wrong constructor dispatchthisArg.Valuereplaced with pattern matching in Replacements.fsTest plan
🤖 Generated with Claude Code