Times should be updated with local times#4268
Conversation
staysgt
left a comment
There was a problem hiding this comment.
looks good so far! left a few comments
| const AMorPM = (time: string, offset: number) => { | ||
| const startTime = Number(time.charAt(0) + (isTwoDigitHour(time) ? time.charAt(1) : '')); | ||
| let AMorPM = time.charAt(time.length - 2) + time.charAt(time.length - 1); | ||
|
|
||
| const flipAMPM = () => { | ||
| if (AMorPM === 'AM') return 'PM'; | ||
| return 'AM'; | ||
| }; | ||
|
|
||
| // if odd, the AM / PM should be flipped | ||
| const doFlip = Math.floor((startTime + offset - 1) / 12) % 2 === 1; | ||
| if (doFlip) AMorPM = flipAMPM(); | ||
|
|
||
| return AMorPM; | ||
| }; |
wavehassman
left a comment
There was a problem hiding this comment.
The bug here is just changing the labels on the availability selector. I'm pretty sure the only changes necessary are reviewTimesInCurrentTimeZone and its three call sites in EditAvailability, SingleAvailabilityView, and AvailabilityScheduleView
| return new Date(year, month, 1 + dayDiff + (nth - 1) * 7); | ||
| }; | ||
|
|
||
| const daylightSavings = () => { |
There was a problem hiding this comment.
Instead of manually computing US DST dates to determine EST's offset, use Intl since the browser already knows it
| @@ -13,6 +13,7 @@ import { useToast } from '../../../hooks/toasts.hooks'; | |||
| import { formatEventTime } from 'shared'; | |||
There was a problem hiding this comment.
formatEventTime(date) with no timezone argument already uses the browser's local timezone because that's dayjs's default behavior
So you don't need to wrap it with formatHourInCurrentTimeZone, you only need to wrap formatHour


Changes
Hours shown on the calendar now will be updated depending on the user's time zone.
If the hours roll over to a new day, the day is also updated accordingly.
Daylight savings is also factored in too.
Test Cases
To Do
Any remaining things that need to get done
Checklist
It can be helpful to check the
ChecksandFiles changedtabs.Please review the contributor guide and reach out to your Tech Lead if anything is unclear.
Please request reviewers and ping on slack only after you've gone through this whole checklist.
yarn.lockchanges (unless dependencies have changed)Closes #4259