Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement LocalDate, OffsetDate and DateInterval #252

Merged
merged 2 commits into from
Jan 24, 2025

Conversation

chrisimcevoy
Copy link
Owner

@chrisimcevoy chrisimcevoy commented Jan 24, 2025

I started out with the aim of porting missing tests and functionality for LocalDate, one thing led to another and...

I ended up fleshing out DateInterval and adding OffsetDate as well.

Noda Time provides LocalDate conversion methods to/from the BCL DateTime. Over in #160, I discussed how these might look in python.

Having thought about it some more, I don't think it makes sense to port those. The reason they exist in Noda Time has a lot to do with .NET not having a discrete date-only type until fairly recently. The existing conversions to/from datetime.date make more sense, and mirror the newer conversion methods to/from DateOnly in Noda Time. It's easier to add these later than it would be to remove them.

I believe this is the first time I've encountered a Noda Time type (DateInterval) which implements both Deconstruct and GetEnumerator, but I could be wrong. At any rate, I came to the conclusion in #248 that __iter__() in Pyoda Time should be reserved for GetEnumerator ports. It's probably more valuable than a deconstructor, which from one point of view is syntactic sugar for assignment which is easily achieved in Python in a more explicit way. Just need to revisit previously-ported classes at some point and make sure the project is consistent about that.

Related to:

Copy link

codecov bot commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 99.86376% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.46%. Comparing base (40d6fe1) to head (57ee9fc).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pyoda_time/_local_date_time.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #252      +/-   ##
==========================================
+ Coverage   96.27%   96.46%   +0.18%     
==========================================
  Files         260      263       +3     
  Lines       20149    20873     +724     
==========================================
+ Hits        19399    20135     +736     
+ Misses        750      738      -12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chrisimcevoy chrisimcevoy merged commit 7783a03 into main Jan 24, 2025
9 checks passed
@chrisimcevoy chrisimcevoy deleted the feat/local-date-and-friends branch January 24, 2025 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant