Skip to content

Improvement for time zone handling - #798

Merged
poppastring merged 2 commits into
mainfrom
fix/timezone-handling-797
Apr 11, 2026
Merged

poppastring merged 2 commits into
mainfrom
fix/timezone-handling-797

Conversation

@poppastring

Copy link
Copy Markdown
Owner

PR Classification

Bug fix and improvement for time zone handling in blog post creation and filtering.

PR Summary

This PR standardizes time zone conversions using NodaTime for blog post creation and filtering logic, ensuring consistent behavior across time zones. It also adds unit tests to verify correct time zone handling.

  • Entry.cs and DayEntry.cs: Refactored filtering methods to convert UTC to local time using NodaTime before comparisons.
  • DasBlogSettings.cs: Updated GetCreateTime to use NodaTime for local-to-UTC conversion.
  • BlogPostViewModelCreator.cs: Set post creation date using NodaTime in the configured time zone.
  • EntryTimezoneFilterTests.cs: Added unit tests for entry and day entry time zone filtering.
  • DasBlogSettingsTests.cs: Added a test to verify GetCreateTime and GetDisplayTime are inverses.

poppastring and others added 2 commits April 10, 2026 23:57
Resolves #797 by addressing three inconsistencies:

1. GetCreateTime() now uses NodaTime InZoneLeniently instead of manual
   offset arithmetic, making it the proper inverse of GetDisplayTime
   and handling DST transitions correctly.

2. XmlRpcManager FillEntryFromMetaWeblogPost now uses GetCreateTime
   (blog timezone) instead of ToUniversalTime (server OS timezone),
   and removes duplicate timezone conversions in metaweblog_newPost
   and blogger_newPost.

3. DayEntry.OccursBetween and Entry.OccursBetween/OccursBefore now
   properly convert UTC dates to local time before comparing,
   consistent with OccursInMonth. DayEntry.OccursInMonth simplified
   to remove manual offset adjustment that conflicted with the fixed
   OccursBetween.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CreateBlogPostVM was using GetUtcOffset(new Instant()) which gets the
offset at Unix epoch instead of now, and offset.Seconds which returns
only the seconds component (not total seconds). Replace with proper
NodaTime Instant.InZone() conversion, consistent with GetDisplayTime.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@poppastring
poppastring merged commit b03fe8a into main Apr 11, 2026
3 checks passed
@poppastring
poppastring deleted the fix/timezone-handling-797 branch April 11, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant