Siva - feature for timezone standardization in EventCard#4633
Siva - feature for timezone standardization in EventCard#4633one-community merged 18 commits intodevelopmentfrom
Conversation
- Added comment indicating where timezone conversion will be implemented - This is the initial step for standardizing event time display based on user timezone
✅ Deploy Preview for highestgoodnetwork-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
eff1ef7 to
f67d61e
Compare
Phase 2 - Setup & Preparation: - Created timezoneUtils.js file with skeleton functions - Added placeholder functions: getUserTimezone, convertToUserTimezone, getTimezoneAbbreviation, formatDateTimeWithTimezone - Added TODO comments explaining what each function will do - No implementation yet - structure only
Phase 3 improvements: - Implemented getUserTimezone() function using Intl.DateTimeFormat API - Added exploration functions for testing date-fns-tz vs moment-timezone approaches - Added comments in EventCard showing where timezone conversion will be implemented - Added import comment (commented out) for future use - Explored conversion options: moment-timezone (already in use) vs date-fns-tz (available) - No full implementation yet - exploration phase only
Phase 4 improvements: - Added moment-timezone import for testing conversion approaches - Enhanced getUserTimezone() with validation and error handling - Implemented test functions for both moment-timezone and date-fns-tz approaches - Added bug fixes: null checks, validation, error handling - Tested timezone detection across browsers (Chrome, Firefox, Safari, Edge) - Documented testing results: decided to use moment-timezone for consistency - Fixed issues found during testing: invalid date handling, null checks - No full implementation yet - testing phase only
- Implemented complete timezone conversion using moment-timezone - Added formatDateTimeWithTimezone function with timezone abbreviation - Updated EventCard to use timezone utilities for time display - Added location placeholder 'Location TBD' for empty locations - Added error handling for date formatting - Removed exploration functions from timezoneUtils - Event times now display in user's local timezone with abbreviation (e.g., '2:00 PM PST')
- Updated timezoneUtils to use current date for timezone abbreviation (ensures all events show same PST/PDT) - Fixed CPDashboard to use timezone utilities for consistent time display - Improved event card alignment for date, time, and location with icons - Fixed EventCard import path - All events now show consistent timezone abbreviation across all cards
…lay, resolve CPDashboard conflict Co-authored-by: Cursor <cursoragent@cursor.com>
… display in eventsContent Co-authored-by: Cursor <cursoragent@cursor.com>
Anusha-Gali
left a comment
There was a problem hiding this comment.
Hi Siva,
I have reviewed your PR locally and have identified the below issues;
- I do not see any mention / example of "Location TBD" in any events
- as you can see below the before and after, how is that the same time in two different events is converted to different times in EDT
Before
**After**
- cannot see the date and time clearly in dark mode
…dark mode readability
…Comments.jsx conflicts
Hi @Anusha-Gali , |
Hi @HemanthNidamanuru |
| } | ||
| }; | ||
|
|
||
| const formatDateTime = (eventDate, timeString) => { |
…e-timezone-conversion
- toFullEventDatetime was calling moment(eventDate) which parsed the date
in the local machine timezone. formatDateTimeWithTimezone then called
.tz(userTimezone) on this already-offset value, causing double conversion
and producing different (wrong) times across different machines.
- Fixed by switching to moment.utc(eventDate) and returning dateM.toISOString()
so the combined datetime is strictly UTC. The single .tz() call in
formatDateTimeWithTimezone then performs the correct, consistent conversion.
- Tightened looksLikeFullDatetime heuristic to only match strings containing 'T'
(strict ISO 8601). The previous check (s.includes('-') && s.length > 12) falsely
matched time-only strings with offsets (e.g. '17:00-05:00'), bypassing the
date-anchoring logic entirely.
- Added eventDate guard in EventCard formatDateTime: if eventDate is missing,
return 'Date not set' instead of silently falling back to local-time parsing.
Fixes reviewer feedback from naznin07 on PR #4633.
35f7c07
All four catch blocks were flagged by SonarQube rule 'Handle this
exception or don't catch it at all' (CWE error-handling):
- fetchEvents catch: err was caught but never referenced — added
console.error so the error variable is explicitly used before
setting the user-facing error message.
- formatDate catch: renamed 'error' -> 'err' for consistency and
confirmed it is passed to console.error.
- formatTime catch: same rename as formatDate.
- parseEventDate catch: already used err in console.error, improved
the message to be more descriptive ('Error parsing event date').
All blocks retain their graceful-degradation behaviour (fallback
return values) so no functional change to the UI.
|
|
Thank you all, merging! |















Standardize Event Time Display Based on User Timezone on Event Cards
Description
Related PRs (if any):
This frontend PR is related to the development backend PR. To test this frontend PR, you need to checkout the development backend PR.
Main changes explained:
src/utils/timezoneUtils.js- Utility module withgetUserTimezone(),convertToUserTimezone(),getTimezoneAbbreviation(), andformatDateTimeWithTimezone()functions for automatic timezone detection and conversionsrc/components/CommunityPortal/CPDashboard.jsx- Integrated timezone utilities to display event times in user's local timezone with abbreviations, added location placeholder handlingsrc/components/CommunityPortal/Event/EventCard/EventCard.jsx- Integrated timezone conversion for event start/end times, improved date/time formatting with error handlingsrc/components/CommunityPortal/CPDashboard.module.css- Improved alignment for event date/time and location icons, added styles for stacked date and time displayisNaN()withNumber.isNaN(), added proper error handling, removed unnecessary commentsHow to test:
npm install && npm run start:localScreenshots or videos of changes:
Before:
After: