Skip to content

Timezone Handling Fix – In Progress#302

Merged
aliihassandev merged 8 commits intomainfrom
fix/blogs-timezone
Apr 17, 2026
Merged

Timezone Handling Fix – In Progress#302
aliihassandev merged 8 commits intomainfrom
fix/blogs-timezone

Conversation

@zainforbjs
Copy link
Copy Markdown
Contributor

Summary

Working on standardizing blog date handling. Current implementation persists dates in UTC and attempts to render in the user’s local timezone.


Known Issues / TODO

  • DST and historical date handling are incorrect; manual UTC offset breaks for past dates.
  • datetime-local inputs risk double conversion on edit.
  • Frontend JS parsing may treat UTC strings as local time if the format is wrong.
  • Old posts are not normalised; mixed local values exist.

Status

  • Backend save/update logic implemented.
  • Frontend conversion partially implemented.
  • Further testing and verification in progress.

@zainforbjs zainforbjs marked this pull request as draft February 18, 2026 15:02
zainforbjs and others added 7 commits February 27, 2026 06:22
Normalize blog date handling to UTC and accept client timezone/date inputs. Replaced inline now() comparisons with toUTC(now()) across Blog and News controllers to ensure consistent UTC-based filtering. On blog create/update: set postCreatedDate, createdAt, updatedAt to UTC, only set publishedAt when a client-supplied date is provided, and convert client ISO datetime strings to UTC via a new toSafeUTC helper. Added toSafeUTC to global functions (parses ISO strings and falls back to current UTC). Frontend create view now injects the user's timezone and sends postCreatedDate (ISO) and userTimezone with HTMX submissions. Adjusted show view check to compare publishedAt against toUTC(now()). These changes prevent timezone-related scheduling/visibility bugs and ensure server-side times are stored/compared in UTC.
Convert blog and comment datetime handling to UTC and improve timezone handling. Replaced Now() comparisons with toUTC(Now()) in blog queries and counts to ensure correct UTC-based filtering; added toUTC and toSafeUTC helpers in global functions (DST-aware Java Calendar offset, robust ISO parsing with fallbacks). Normalize publishedAt/postCreatedDate when creating/updating posts and comments (use toSafeUTC/toUTC). Add data-utc attributes to view date elements for client-side handling. Also includes small whitespace/validation cleanups.
@aliihassandev aliihassandev marked this pull request as ready for review April 17, 2026 14:57
@aliihassandev aliihassandev merged commit 010f7d6 into main Apr 17, 2026
2 checks passed
@aliihassandev aliihassandev deleted the fix/blogs-timezone branch April 17, 2026 14:57
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.

2 participants