-
Notifications
You must be signed in to change notification settings - Fork 247
Refactor CalDateTime and DateTimeSerializer #631
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
Conversation
I want to make a change to CalDateTime.ToString and want to be confident that I'm not breaking existing functionality. These tests pass against the current code.
Refactor CalDateTime and DateTimeSerializer CalDateTime * to use DateOnly and TimeOnly types * Added SetValue(DateOnly date, TimeOnly? time, DateTimeKind kind) to set the value of the date and time properly. * Refactored `ToString` overloads to convert the date and time to a string representation. * marked some properties as obsolete. * Updated related tests and methods to accommodate these changes. * Increase code coverage > 90% DateTimeSerializer * Added validation in the `SerializeToString` method to ensure the TZID parameter is correctly handled based on whether the date-time is in UTC. * Improved the Deserialize method to handle both full date-time and date-only strings, initializing the DateOnly and TimeOnly parts accordingly. * Increase code coverage > 90% Added new package reference `Portable.System.DateTimeOnly` for netstandard2.0 and netstandard2.1 for compatibility with net6.0 and later. Fixes ical-org#630
4a8a0b3 to
f10055b
Compare
CI build processes now use `-p:Nullable=disable` to avoid breaking changes while we gradually migrate to NRT
92ce653 to
9354b4b
Compare
* The method now re-initializes the `CalDateTime` instance, appying the same rules as from CTORs. * `IDateTime` has NRT enabled * SetValue returns the current instance, enabling method chaining. * Updated related methods to use this new behavior. * Remove redundant HasTime check in Period.StarTime getter * Added tests to verify SetValue behavior.
|
@minichma From my understanding we should also care about the following:
I'll set the PR back to draft, and work on what's mentioned above. What do you think? (Anything else to consider?) |
|
@axunonb That's great work! I'll try to find some time for a review later today, or at the weekend at the latest. The handling of the different DateTimeKinds seems to stay challenging. I commented on the topic within the v5 project. Will comment more after my review. |
|
@minichma Hm, I'm not so convinced any more of the current implementation. In connection with leaving |
|
|
Closing the PR in favor of #638 |



CalDateTime
DateOnlyandTimeOnlyin order to return correct values forCalDateTime.HasTimeandCalDateTime.HasDateif even if hour, minutes and seconds are zero.SetValue(DateOnly, TimeOnly?, DateTimeKind)to set the value of the date and time properly.ToStringoverloads to convert the date and time to a string representation. Thanks to @nzbart for his initial PR.DateTimeSerializer
SerializeToStringmethod to ensure the TZID parameter is correctly handled based on whether the date-time is in UTC.DateOnlyandTimeOnlyparts accordingly.Other
IDateTime-p:Nullable=disableto avoid breaking changes while we gradually migrate to NRTPortable.System.DateTimeOnlyfor netstandard2.0 and netstandard2.1 for compatibility with net6.0 and later.Fixes #630
Fixes #633