Use Slack's built-in timezone formatting for event notification times#250
Conversation
|
@copilot let's change this up - make the message that we send to slack, utilize slacks built in time zone parsing so that depending on the timezone the user is in, the message will render dates correctly |
Done in commit For a same-day timed event the message line looks like: Slack renders that as e.g. |
There was a problem hiding this comment.
Pull request overview
Replaces the hardcoded locale/timezone formatting in the event alert job with Slack's <!date^…> mrkdwn syntax, so each Slack user sees event times rendered in their own Slack timezone. UTC is retained as the fallback text and for date-grouping comparisons.
Changes:
- Introduce
formatUtcDateLabel,formatUtcTimeLabel,toUnixSeconds, andslackTimestamphelpers. - Rework
formatOccurrenceWindowfor timed events to emit Slack date tokens (same-day and cross-day variants); all-day events keep plain UTC labels. - Update tests to assert the new
<!date^…>token output with correct Unix seconds and UTC fallback text.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/backend/src/jobs/event-alert.job.ts | Replaces locale-based time formatting with Slack timestamp tokens for per-user timezone rendering. |
| packages/backend/src/jobs/event-alert.job.spec.ts | Adds assertions verifying <!date^…> tokens, Unix second values, and UTC fallback strings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Event alert notifications displayed times using the server's system locale (typically UTC). This updates the job to use Slack's
<!date^…>syntax so that each recipient sees event times rendered automatically in their own Slack timezone setting.Changes
slackTimestamphelper — wraps aDatein Slack's<!date^UNIX_TS^{format}|fallback>syntax, enabling per-user timezone rendering by Slack clients.formatUtcDateLabel— formats a date as "Mon Day" in UTC; used for all-day event labels and as a reference for same-day comparison.formatUtcTimeLabel— formats a time as a 12-hour UTC string; used as fallback text inside<!date^…>tokens for clients that don't support mrkdwn date formatting.formatOccurrenceWindow— timed events now emit Slack date tokens instead of hardcoded timezone strings:<!date^TS^{date_short}|Apr 21>, <!date^TS^{time}|4:00 PM> - <!date^TS^{time}|5:00 PM><!date^TS^{date_short} at {time}|…> - <!date^TS^{date_short} at {time}|…><!date^…>tokens with correct Unix second values and UTC fallback text.Original prompt
This pull request was created from Copilot chat.