Fix birthday time offset and date locale #66

Merged
norm merged 1 commit from fix/date into main 2022-08-15 18:45:57 +00:00
Owner

The user's configred birthday is stored as UTC time, so use that for display as well.
This means the birthday won't be shown as a day behind or ahead depending on the user's browser timezone.

Also use the locale configured in the user's client settings in Misskey for date formatting.

The user's configred birthday is stored as UTC time, so use that for display as well. This means the birthday won't be shown as a day behind or ahead depending on the user's browser timezone. Also use the locale configured in the user's client settings in Misskey for date formatting.
Johann150 approved these changes 2022-08-15 15:24:14 +00:00
Johann150 left a comment
Owner

Strictly speaking the birthday is stored without time zone information. To my knowledge of ISO 8601 this means local time zone should be assumed. (Which is of course not what Javascript does with new Date()...)

Anyway, I guess synchronizing what JavaScript thinks the time is with what it is being formatted as should fix the problem for absolute. It might cause problems if resolutions of hours or below are being used, but that is not the case here so I don't think it should be a problem.

Strictly speaking the birthday is stored without time zone information. To my knowledge of ISO 8601 this means local time zone should be assumed. (Which is of course not what Javascript does with `new Date()`...) Anyway, I guess synchronizing what JavaScript thinks the time is with what it is being formatted as should fix the problem for `absolute`. It might cause problems if resolutions of hours or below are being used, but that is not the case here so I don't think it should be a problem.
@ -21,3 +24,4 @@
const _time = typeof props.time === 'string' ? new Date(props.time) : props.time;
const absolute = ((): string => {
const timeZone = props.utc ? 'UTC' : Intl.DateTimeFormat().resolvedOptions().timeZone;
Owner

I'd maybe have written this in a way that the second parameter to toLocale...String is just an empty object if UTC is not given. But this should work just as well.

I'd maybe have written this in a way that the second parameter to `toLocale...String` is just an empty object if UTC is not given. But this should work just as well.
norm marked this conversation as resolved
norm force-pushed fix/date from 7940747c7d to 1cb5856f7c 2022-08-15 17:11:59 +00:00 Compare
norm merged commit bb073670ef into main 2022-08-15 18:45:57 +00:00
norm deleted branch fix/date 2022-08-15 18:45:57 +00:00
Sign in to join this conversation.
No reviewers
No labels
feature
fix
upkeep
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: FoundKeyGang/FoundKey#66
No description provided.