feat: add timezone configuration in app settings#3530
feat: add timezone configuration in app settings#3530devin-ai-integration[bot] wants to merge 2 commits intomainfrom
Conversation
- Add timezone field to generalSchema in packages/store/src/zod.ts - Add timezone to ConfigKey and CONFIG_REGISTRY - Create TimezoneView component for selecting timezone in settings - Create useTimezone hook and timezone utility functions - Update timeline item date formatting to use configured timezone - Update search item date formatting to use configured timezone This allows users to configure their preferred timezone for displaying dates and times throughout the app, addressing the issue where users in different timezones (e.g., London) see incorrect times. Co-Authored-By: john@hyprnote.com <john@hyprnote.com>
✅ Deploy Preview for hyprnote ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for hyprnote-storybook canceled.
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| @@ -416,11 +425,16 @@ function formatDisplayTime( | |||
|
|
|||
| const sameYear = date.getFullYear() === new Date().getFullYear(); | |||
There was a problem hiding this comment.
The year comparison logic is broken when using a configured timezone. new Date().getFullYear() uses the system timezone, while date will be formatted using the configured timezone. This causes incorrect display logic when the system and configured timezones are in different calendar years.
For example, if it's December 31, 2025 11PM PST (system) but the configured timezone is JST (16 hours ahead = January 1, 2026), the comparison will incorrectly compare 2025 (system) with a date that displays as 2026 (configured), causing the year to be shown/hidden incorrectly.
Fix:
Create the current date in the configured timezone for comparison:
const nowInTimezone = new Date().toLocaleString('en-US', { timeZone: timezone });
const currentYear = new Date(nowInTimezone).getFullYear();
const dateInTimezone = date.toLocaleString('en-US', { timeZone: timezone });
const dateYear = new Date(dateInTimezone).getFullYear();
const sameYear = dateYear === currentYear;| hour: "numeric", | |
| minute: "numeric", | |
| timeZone: timezone, | |
| }); | |
| if (precision === "time") { | |
| const nowInTimezone = new Date().toLocaleString('en-US', { timeZone: timezone }); | |
| const currentYear = new Date(nowInTimezone).getFullYear(); | |
| const dateInTimezone = date.toLocaleString('en-US', { timeZone: timezone }); | |
| const dateYear = new Date(dateInTimezone).getFullYear(); | |
| const sameYear = dateYear === currentYear; |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
Co-Authored-By: john@hyprnote.com <john@hyprnote.com>
feat: add timezone configuration in app settings
Summary
Adds a timezone configuration option to the app settings, allowing users to select their preferred timezone for displaying dates and times. This addresses the issue where users in different timezones (e.g., London) see incorrect times in the app.
Changes:
timezonefield to the general settings schema (packages/store/src/zod.ts)timezonetoSETTINGS_MAPPINGin TinyBase store for proper persistenceTimezoneViewcomponent with a dropdown of 21 common timezones plus a "System" optionuseTimezonehook that returns the configured timezone or falls back to system timezoneUpdates since last revision
timezonetoSETTINGS_MAPPING.valuesinsettings.tsstring | undefinedinregistry.tsto fix form field type inferenceReview & Testing Checklist for Human
export-pdf.tsx,shared.tsx, andcontacts/details.tsxstill use system timezone - verify if these should also be updatedRecommended test plan:
Notes
Link to Devin run: https://app.devin.ai/sessions/9a3f7fa768c54ba3886cc7f6d4c9ef4c
Requested by: @ComputelessComputer