Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

update date logic to account for timezones (#3840)

authored by

Samuel Newman and committed by
GitHub
a5511e3c 051e897a

+12 -4
+12 -4
src/components/dms/MessageItem.tsx
··· 118 118 } 119 119 120 120 // if in the last day 121 - if (now.toISOString().slice(0, 10) === date.toISOString().slice(0, 10)) { 121 + if (localDateString(now) === localDateString(date)) { 122 122 return time 123 123 } 124 124 125 125 // if yesterday 126 126 const yesterday = new Date(now) 127 127 yesterday.setDate(yesterday.getDate() - 1) 128 - if ( 129 - yesterday.toISOString().slice(0, 10) === date.toISOString().slice(0, 10) 130 - ) { 128 + 129 + if (localDateString(yesterday) === localDateString(date)) { 131 130 return _(msg`Yesterday, ${time}`) 132 131 } 133 132 ··· 164 163 </TimeElapsed> 165 164 ) 166 165 } 166 + 167 + function localDateString(date: Date) { 168 + // can't use toISOString because it should be in local time 169 + const mm = date.getMonth() 170 + const dd = date.getDate() 171 + const yyyy = date.getFullYear() 172 + // not padding with 0s because it's not necessary, it's just used for comparison 173 + return `${yyyy}-${mm}-${dd}` 174 + }