Merge pull request 'Fix birthday time offset and date locale' (#66) from fix/date into main
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/push/test Pipeline failed

Reviewed-on: #66
This commit is contained in:
Norm 2022-08-15 18:45:56 +00:00
commit bb073670ef
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>