Skip to content

Use Slack's built-in timezone formatting for event notification times#250

Merged
sfreeman422 merged 3 commits into
masterfrom
copilot/modify-events-notification-to-est
May 14, 2026
Merged

Use Slack's built-in timezone formatting for event notification times#250
sfreeman422 merged 3 commits into
masterfrom
copilot/modify-events-notification-to-est

Conversation

Copy link
Copy Markdown

Copilot AI commented May 14, 2026

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

  • slackTimestamp helper — wraps a Date in 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:
    • Same UTC calendar day: <!date^TS^{date_short}|Apr 21>, <!date^TS^{time}|4:00 PM> - <!date^TS^{time}|5:00 PM>
    • Cross-day: <!date^TS^{date_short} at {time}|…> - <!date^TS^{date_short} at {time}|…>
    • All-day events continue to use plain UTC date labels (no clock time involved).
Before (hardcoded EST): Apr 21, 12:00 PM - 1:00 PM EDT
After (Slack-rendered): Apr 21, 2026, 12:00 PM - 1:00 PM  ← EST user
                        Apr 21, 2026, 4:00 PM - 5:00 PM   ← UTC user
  • Tests — updated assertions to verify <!date^…> tokens with correct Unix second values and UTC fallback text.
Original prompt

Modify the events notification job so that all event times are displayed in Eastern Standard Time (EST) instead of UTC. Additionally, update the job logic to ensure that alerts are shown or suppressed based on EST rather than UTC. This includes:

  • Converting time values from UTC to EST when displaying notifications.
  • Adjusting any time-based triggers or filtering logic so that scheduling and cutoffs occur according to EST.
  • Ensuring this is applied throughout any part of the notification or alerting code that references the current time or a user's local time.
  • Update any documentation or test cases as needed to reflect this time zone change.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Current user's login: sfreeman422

User: modify the events notification job to display in EST not UTC - consider this time zone when choosing to display alerts or not

Assistant: To proceed, I can open a pull request to update the event notification job so that it displays times in EST instead of UTC, and also ensures that alert logic considers EST for determining when to display alerts. Please specify the repository (owner/name) where you want this change to be made.

Assistant: New message from Copilot

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Update events notification job to use Eastern Standard Time Display event notification times in Eastern time (America/New_York) May 14, 2026
Copilot AI requested a review from sfreeman422 May 14, 2026 01:20
@sfreeman422
Copy link
Copy Markdown
Collaborator

@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

Copy link
Copy Markdown
Author

Copilot AI commented May 14, 2026

@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 correc...

Done in commit 9e7e114. Event times now use Slack's <!date^UNIX_TS^{format}|fallback> syntax — Slack automatically renders each timestamp in the viewing user's own timezone setting.

For a same-day timed event the message line looks like:

- <!date^1776787200^{date_short}|Apr 21>, <!date^1776787200^{time}|4:00 PM> - <!date^1776790800^{time}|5:00 PM> - Planning 🚀 @ HQ

Slack renders that as e.g. Apr 21, 2026, 12:00 PM - 1:00 PM for an EST user, Apr 21, 2026, 4:00 PM - 5:00 PM for a UTC user, etc. The fallback text (after |) is the UTC value for clients that don't support the mrkdwn date format. All-day events continue to use plain UTC date labels since they have no clock-time component.

Copilot AI changed the title Display event notification times in Eastern time (America/New_York) Use Slack's built-in timezone formatting for event notification times May 14, 2026
@sfreeman422 sfreeman422 marked this pull request as ready for review May 14, 2026 14:18
Copilot AI review requested due to automatic review settings May 14, 2026 14:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and slackTimestamp helpers.
  • Rework formatOccurrenceWindow for 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.

@sfreeman422 sfreeman422 merged commit 7bdfa9a into master May 14, 2026
14 checks passed
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.

3 participants