From 1fd93eaabb8402004ccae03493d507505c6ff3dc Mon Sep 17 00:00:00 2001 From: lesion Date: Tue, 3 Oct 2023 12:45:37 +0200 Subject: [PATCH] add ampm / 24h support, #294, #264, update changelog --- CHANGELOG | 8 +++++--- components/DateInput.vue | 8 ++++---- docs/changelog.md | 11 ++++++++++- pages/event/_slug.vue | 2 +- plugins/time.js | 23 +++++++++++++++++++---- yarn.lock | 18 ++++-------------- 6 files changed, 43 insertions(+), 27 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 95d7d7ac..6c0c1b8b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,11 +1,13 @@ All notable changes to this project will be documented in this file. -### .... + +### 1.6.15 - 3 Oct '23 - [feat] clone event - - [feat] include Brazilian Portuguese (pt-br) and Portugual Portuguese (pt-pt) [#292](https://framagit.org/les/gancio/-/issues/292) + - [feat] am/pm / 24hr support, fix [#294](https://framagit.org/les/gancio/-/issues/294) [#264](https://framagit.org/les/gancio/-/issues/264) - [feat] update telegram plugin bridge to v1.0.3, [#299](https://framagit.org/les/gancio/-/issues/299) - - [fix] CLI has to fail when configuration not present [#284](https://framagit.org/les/gancio/-/issues/284) + - [feat] include Brazilian Portuguese (pt-br) and Portugual Portuguese (pt-pt) [#292](https://framagit.org/les/gancio/-/issues/292) - [fix] MariaDB JSON fields manual fix - [fix] improve some corner case with SMTP From field [#297](https://framagit.org/les/gancio/-/issues/297) + - [fix] CLI has to fail when configuration not present [#284](https://framagit.org/les/gancio/-/issues/284) - [minor] remove html2text dep from client - [minor] RSS item's title format is now YYYY-MM-DD, [#300](https://framagit.org/les/gancio/-/issues/300) diff --git a/components/DateInput.vue b/components/DateInput.vue index a2250a70..6c5ba654 100644 --- a/components/DateInput.vue +++ b/components/DateInput.vue @@ -47,7 +47,7 @@ v-col(cols=12) :clear-icon='mdiClose' @click:clear='() => change("fromHour")' :label="$t('event.from')" - :value="value.fromHour" + :value="$time.formatHour(value.fromHour)" :disabled='!value.from' readonly :prepend-icon="mdiClockTimeFourOutline" @@ -59,7 +59,7 @@ v-col(cols=12) :value="value.fromHour" :allowedMinutes='allowedMinutes' full-width - format='24hr' + :format='$time.timeFormat()' @click:minute='menuFromHour = false' @input='hr => change("fromHour", hr)') @@ -79,7 +79,7 @@ v-col(cols=12) :clear-icon='mdiClose' @click:clear='() => change("dueHour")' :label="$t('event.due')" - :value="value.dueHour" + :value="$time.formatHour(value.dueHour)" :disabled='!value.fromHour' readonly :prepend-icon="mdiClockTimeEightOutline" @@ -90,7 +90,7 @@ v-col(cols=12) :value="value.dueHour" full-width :allowedMinutes='allowedMinutes' - format='24hr' + :format='$time.timeFormat()' @click:minute='menuDueHour = false' @input='hr => change("dueHour", hr)') diff --git a/docs/changelog.md b/docs/changelog.md index 339ebf69..f2bdc41a 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -5,8 +5,17 @@ permalink: /changelog nav_order: 10 --- - All notable changes to this project will be documented in this file. +### 1.6.15 - 3 Oct '23 + - [feat] clone event + - [feat] am/pm / 24hr support, fix [#294](https://framagit.org/les/gancio/-/issues/294) [#264](https://framagit.org/les/gancio/-/issues/264) + - [feat] update telegram plugin bridge to v1.0.3, [#299](https://framagit.org/les/gancio/-/issues/299) + - [feat] include Brazilian Portuguese (pt-br) and Portugual Portuguese (pt-pt) [#292](https://framagit.org/les/gancio/-/issues/292) + - [fix] MariaDB JSON fields manual fix + - [fix] improve some corner case with SMTP From field [#297](https://framagit.org/les/gancio/-/issues/297) + - [fix] CLI has to fail when configuration not present [#284](https://framagit.org/les/gancio/-/issues/284) + - [minor] remove html2text dep from client + - [minor] RSS item's title format is now YYYY-MM-DD, [#300](https://framagit.org/les/gancio/-/issues/300) ### 1.6.14 - 30 June '23 - improve CLI accounts operations ([documentation](https://gancio.org/usage/cli)) diff --git a/pages/event/_slug.vue b/pages/event/_slug.vue index 1dcda560..0a68afa7 100644 --- a/pages/event/_slug.vue +++ b/pages/event/_slug.vue @@ -19,7 +19,7 @@ v-container#event.h-event.pa-2.pa-sm-2(v-touch="{ left: goNext, right: goPrev }" v-container.eventDetails time.dt-start(:datetime='$time.unixFormat(event.start_datetime, "yyyy-MM-dd HH:mm")' itemprop="startDate" :content='$time.unixFormat(event.start_datetime, "yyyy-MM-dd\'T\'HH:mm")') v-icon(v-text='mdiCalendar' small) - strong.ml-2.text-uppercase {{$time.when(event)}} + span.ml-2.text-uppercase {{$time.when(event)}} .d-none.dt-end(v-if='event.end_datetime' itemprop="endDate" :content='$time.unixFormat(event.end_datetime,"yyyy-MM-dd\'T\'HH:mm")') {{$time.unixFormat(event.end_datetime,"yyyy-MM-dd'T'HH:mm")}} div.font-weight-light.mb-3 {{$time.from(event.start_datetime)}} small(v-if='event.parentId') ({{$time.recurrentDetail(event)}}) diff --git a/plugins/time.js b/plugins/time.js index 1097534a..e09ec09d 100644 --- a/plugins/time.js +++ b/plugins/time.js @@ -4,6 +4,21 @@ export default ({ app, store }, inject) => { Settings.defaultLocale = app.i18n.locale || store.state.settings.instance_locale const time = { + timeFormat () { + const time = DateTime.fromObject({ hour: 14 }, { + zone: store.state.settings.instance_timezone, + locale: app.i18n.locale || store.state.settings.instance_locale + }).toLocaleString({ hour: 'numeric'}) + return time === '2 PM' ? 'ampm' : '24hr' + }, + + formatHour (value, format) { + return DateTime.fromFormat(value, 'HH:mm', { + zone: store.state.settings.instance_timezone, + locale: app.i18n.locale || store.state.settings.instance_locale + }).toLocaleString({ hour: '2-digit', minute: '2-digit'}) + }, + format (date, format) { return DateTime.fromISO(date, { zone: store.state.settings.instance_timezone, @@ -46,11 +61,11 @@ export default ({ app, store }, inject) => { } const start = DateTime.fromSeconds(event.start_datetime, opt) - let time = start.toFormat('EEEE d MMMM HH:mm') + let time = start.toLocaleString({ weekday: 'long', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }) const end = event.end_datetime && DateTime.fromSeconds(event.end_datetime, opt) if (end) { - time += event.multidate ? ` → ${end.toFormat('EEEE d MMMM')}` : `-${end.toFormat('HH:mm')}` + time += event.multidate ? ` → ${end.toLocaleString({ weekday: 'long', month: 'short', day: '2-digit'})}` : `-${end.toLocaleString({hour: '2-digit', minute: '2-digit'})}` } if (currentYear !== start.year) { @@ -78,9 +93,9 @@ export default ({ app, store }, inject) => { const { frequency, type } = parent.recurrent let recurrent if (frequency === '1w' || frequency === '2w') { - recurrent = app.i18n.t(`event.recurrent_${frequency}_days`, { days: DateTime.fromSeconds(parent.start_datetime).toFormat('EEEE') }) + recurrent = app.i18n.t(`event.recurrent_${frequency}_days`, { days: DateTime.fromSeconds(parent.start_datetime).toLocaleString('EEEE') }) } else if (frequency === '1m' || frequency === '2m') { - const d = type === 'ordinal' ? DateTime.fromSeconds(parent.start_datetime).day : DateTime.fromSeconds(parent.start_datetime).toFormat('EEEE') + const d = type === 'ordinal' ? DateTime.fromSeconds(parent.start_datetime).day : DateTime.fromSeconds(parent.start_datetime).toLocaleString('EEEE') if (type === 'ordinal') { recurrent = app.i18n.t(`event.recurrent_${frequency}_days`, { days: d }) } else { diff --git a/yarn.lock b/yarn.lock index 9998f375..3f353a16 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4149,20 +4149,10 @@ caniuse-api@^3.0.0: lodash.memoize "^4.1.2" lodash.uniq "^4.5.0" -caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001449: - version "1.0.30001468" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001468.tgz#0101837c6a4e38e6331104c33dcfb3bdf367a4b7" - integrity sha512-zgAo8D5kbOyUcRAgSmgyuvBkjrGk5CGYG5TYgFdpQv+ywcyEpo1LOWoG8YmoflGnh+V+UsNuKYedsoYs0hzV5A== - -caniuse-lite@^1.0.30001503: - version "1.0.30001517" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001517.tgz#90fabae294215c3495807eb24fc809e11dc2f0a8" - integrity sha512-Vdhm5S11DaFVLlyiKu4hiUTkpZu+y1KA/rZZqVQfOD5YdDT/eQKlkt7NaE0WGOFgX32diqt9MiP9CAiFeRklaA== - -caniuse-lite@^1.0.30001523, caniuse-lite@^1.0.30001538: - version "1.0.30001538" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001538.tgz#9dbc6b9af1ff06b5eb12350c2012b3af56744f3f" - integrity sha512-HWJnhnID+0YMtGlzcp3T9drmBJUVDchPJ08tpUGFLs9CYlwWPH2uLgpHn8fND5pCgXVtnGS3H4QR9XLMHVNkHw== +caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001449, caniuse-lite@^1.0.30001503, caniuse-lite@^1.0.30001523, caniuse-lite@^1.0.30001538: + version "1.0.30001541" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001541.tgz" + integrity sha512-bLOsqxDgTqUBkzxbNlSBt8annkDpQB9NdzdTbO2ooJ+eC/IQcvDspDc058g84ejCelF7vHUx57KIOjEecOHXaw== chalk@^2.0.0, chalk@^2.3.2, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2"