Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to use DateOnly and TimeOnly for date/time handling (ical-or…
…g#658) Increased `CalDateTime` immutability CalDateTime: * `Date` is of type `DateOnly` (breaking vs. v4) * Make `UtzTzId` a public string * Remove `DateOnlyValue` * Remove `HasDate` (always true) (breaking vs. v4) * Remove `Millisecond` (breaking vs. v4) * Remove `Ticks` (breaking vs. v4) * Remove overload CalDateTime(int year, int month, int day, string? tzId) (breaking vs. v4) * `HasTime` only has a getter (breaking vs. v4) * `Time` is a getter of type `TimeOnly`. Values are always rounded to the nearest second (breaking vs. v4) * `AddMilliseconds` takes `double` as argument, like `DateTime.AddMilliseconds` (breaking vs. v4) * Remove `TimeOnlyValue` * `Value` only has a getter (breaking vs. v4) * `TzId` only has a getter (breaking vs. v4) * Remove `AsSystemLocal` (breaking vs. v4) * Remove `AsDateTimeOffset` (breaking vs. v4) * Remove `AddMilliseconds` (breaking vs. v4) * Remove `AddTicks` (breaking vs. v4) * Remove unused `TimeSpan? operator -(CalDateTime? left, IDateTime? right)` (breaking vs. v4) * Update Equality operators for comparing to floating date/time (breaking vs. v4) IDateTime (breaking vs. v4): * Remove `AsSystemLocal` (breaking vs. v4)` * Remove `AsDateTimeOffset` (breaking vs. v4)` * Remove `AddMilliseconds` (breaking vs. v4) * Remove `AddTicks` (breaking vs. v4) * Remove `Millisecond` (breaking vs. v4) * Remove `Ticks` (breaking vs. v4) * Add explicit bool IsFloating (implicit TzId == null) * `Date` is a getter of type `DateOnly` * `Time` is a getter of type `TimeOnly` * `HasTime` only has a getter * Remove `HasDate` (always true) (breaking vs. v4) * `Value` only has a getter * `TzId` only has a getter * `ToTimeZone(string?)` argument is a NRT Miscellaneous: * CTORs with `DateTime` arguments persist. Actually they are also comfortable, and now consistently processed * Keep `IDateTime` - maybe in another PR * Transitioned from DateTime to DateOnly and TimeOnly across the codebase for improved date and time handling. * Updated methods, properties, and tests to ensure compatibility with the new approach. * Updated xmldoc Resolves ical-org#656 Resolves ical-org#662 * Remove AsDateTimeOffset from IDateTime and CalDateTime * Floating date/time can convert to any timezone ID, keeping Value unchanged Remove fallback to system's local timezone for floating date/time * Added unit test GetOccurrenceShouldExcludeDtEndZoned Resolves ical-org#660 * Fix: Initialize CalDateTime with timezone UTC only, if TimeOnly is not null Reasoning: DATE cannot have a timezone * Refactor time handling and remove millisecond/ticks methods * Updated CalDateTime to truncate time to seconds instead of rounding. * Removed AddMilliseconds and AddTicks methods and related test cases. * Fix: minus and plus operators for cases where time parts are equal * Adjusted EndOfDay method to use AddSeconds(-1) instead of AddTicks(-1) * Removed GetOccurrenceShouldExcludeDtEndZoned test. * Remove setter from `CalendarEvent.AllDay` * Made `IsAllDay` in `CalendarEvent.cs` read-only, * Updated `Issue432_AllDay` unit test in `RecurrenceTests.cs` to remove time component from `Start` property and eliminate setting the `IsAllDay` property. (The only place where the setter was used.) * Simplified `CalDateTime.cs` initialization by removing condition related to `UtcTzId` when `timeOnly` is not provided. * Ensure transitive equality for CalDateTime * `operator ==`: if (left.IsFloating != right.IsFloating) return false; * Add unit test * Remove properties `Ticks` and `Millisecond` * Remove redundant if clause * Simplify end period creation in GetOccurrences method Removed the `endTimeOnly` variable and its usage in the `GetOccurrences` method. The code now directly creates the `CalDateTime` object for the end of the period without adjusting the time component. This change streamlines the code and avoids potential issues related to time adjustments. * Simplify GetOccurrences methods by removing time adjustments The `GetOccurrences` methods in `Calendar.cs` have been simplified by removing the code that adjusted the end time by subtracting one second or one tick. The methods now directly use the start date and the date one day after the start date without adjusting the time component. This change simplifies the logic and removes unnecessary time adjustments. The adjustments are redudant, because public static HashSet<Occurrence> RecurrenceUtil.GetOccurrences(IRecurrable recurrable, IDateTime periodStart, IDateTime periodEnd, bool includeReferenceDateInResults) uses precise "LessThan" for comparing end date/times Resolves ical-org#662
- Loading branch information