Fix include seconds option in datetime interface

Fixes #951
This commit is contained in:
rijkvanzanten
2020-11-11 13:48:11 -05:00
parent e3af581e8e
commit 93b85477c7
2 changed files with 7 additions and 4 deletions

View File

@@ -56,8 +56,8 @@
<script lang="ts">
import { defineComponent, ref, watch, computed, reactive, PropType } from '@vue/composition-api';
import formatLocalized from '@/utils/localized-format';
import { i18n } from '@/lang';
import formatLocalized from '../../utils/localized-format';
import { i18n } from '../../lang';
import { formatISO, parseISO, format, parse } from 'date-fns';
type LocalValue = {
@@ -266,10 +266,12 @@ export default defineComponent({
return;
}
let format = `${i18n.t('date-fns_date')} ${i18n.t('date-fns_time')}`;
const timeFormat = props.includeSeconds ? 'date-fns_time' : 'date-fns_time_no_seconds';
let format = `${i18n.t('date-fns_date')} ${i18n.t(timeFormat)}`;
if (props.type === 'date') format = String(i18n.t('date-fns_date'));
if (props.type === 'time') format = String(i18n.t('date-fns_time'));
if (props.type === 'time') format = String(i18n.t(timeFormat));
displayValue.value = await formatLocalized(_value.value, format);
}

View File

@@ -394,6 +394,7 @@
"date-fns_datetime": "PPP h:mma",
"date-fns_date": "PPP",
"date-fns_time": "h:mm:ss a",
"date-fns_time_no_seconds": "h:mm a",
"date-fns_date_short": "MMM d, u",
"date-fns_time_short": "h:mma",
"date-fns_date_short_no_year": "MMM d",