Fix birthday time offset and date locale
Some checks failed
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/lint-backend Pipeline was successful
ci/woodpecker/push/test Pipeline failed
ci/woodpecker/pr/lint-client Pipeline failed
ci/woodpecker/pr/test Pipeline failed

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.
This commit is contained in:
Norm 2022-08-14 23:59:50 -04:00
parent a07b464690
commit 1cb5856f7c
2 changed files with 8 additions and 4 deletions

View file

@ -9,22 +9,26 @@
<script lang="ts" setup>
import { onUnmounted } from 'vue';
import { i18n } from '@/i18n';
import { lang } from '@/config';
const props = withDefaults(defineProps<{
time: Date | string;
format?: 'both' | 'date' | 'time';
mode?: 'relative' | 'absolute' | 'detail';
utc?: boolean;
}>(), {
format: 'both',
mode: 'relative',
utc: false,
});
const _time = typeof props.time === 'string' ? new Date(props.time) : props.time;
const absolute = ((): string => {
const options = props.utc ? { timeZone: 'UTC' } : {};
switch (props.format) {
case 'date': return _time.toLocaleDateString();
case 'time': return _time.toLocaleTimeString();
default: return _time.toLocaleString();
case 'date': return _time.toLocaleDateString(lang ?? 'en-US', options);
case 'time': return _time.toLocaleTimeString(lang ?? 'en-US', options);
default: return _time.toLocaleString(lang ?? 'en-US', options);
}
})();

View file

@ -51,7 +51,7 @@
</dl>
<dl v-if="user.birthday" class="field">
<dt class="name"><i class="fas fa-birthday-cake fa-fw"></i> {{ i18n.ts.birthday }}</dt>
<dd class="value"><MkTime format="date" mode="detail" :time="user.birthday"/></dd>
<dd class="value"><MkTime format="date" mode="detail" :time="user.birthday" :utc="true"/></dd>
</dl>
<dl class="field">
<dt class="name"><i class="fas fa-calendar-alt fa-fw"></i> {{ i18n.ts.registeredDate }}</dt>