diff --git a/source/connector-mobilizon/front/date-time-wrapper-test.js b/source/connector-mobilizon/front/date-time-wrapper-test.js index c29f87d..776cc5a 100644 --- a/source/connector-mobilizon/front/date-time-wrapper-test.js +++ b/source/connector-mobilizon/front/date-time-wrapper-test.js @@ -2,42 +2,42 @@ import test from 'ava' import DateTimeWrapper from './date-time-wrapper' test('#getShortDate usual date', t => { - const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' }) + const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' }) t.is(d.getShortDate(), '24/12/2020') }) test('#get24Time usual time', t => { - const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' }) + const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' }) t.is(d.get24Time(), '16:45') }) test('#equalsDate same date, different time', t => { - const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' }) - const e = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T17:46:01Z' }) + const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' }) + const e = new DateTimeWrapper({ text: '2020-12-24T17:46:01Z' }) t.true(d.equalsDate(e)) }) test('#equalsDate different date, different time', t => { - const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' }) - const e = new DateTimeWrapper({ locale: 'en-GB', text: '2021-11-25T17:46:01Z' }) + const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' }) + const e = new DateTimeWrapper({ text: '2021-11-25T17:46:01Z' }) t.false(d.equalsDate(e)) }) test('#equalsDate different day, different time', t => { - const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' }) - const e = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-25T17:46:01Z' }) + const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' }) + const e = new DateTimeWrapper({ text: '2020-12-25T17:46:01Z' }) t.false(d.equalsDate(e)) }) test('#equalsDate different month, different time', t => { - const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' }) - const e = new DateTimeWrapper({ locale: 'en-GB', text: '2020-11-24T17:46:01Z' }) + const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' }) + const e = new DateTimeWrapper({ text: '2020-11-24T17:46:01Z' }) t.false(d.equalsDate(e)) }) test('#equalsDate different year, different time', t => { - const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' }) - const e = new DateTimeWrapper({ locale: 'en-GB', text: '2021-12-24T17:46:01Z' }) + const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' }) + const e = new DateTimeWrapper({ text: '2021-12-24T17:46:01Z' }) t.false(d.equalsDate(e)) }) diff --git a/source/connector-mobilizon/front/date-time-wrapper.js b/source/connector-mobilizon/front/date-time-wrapper.js index 0294735..b16b981 100644 --- a/source/connector-mobilizon/front/date-time-wrapper.js +++ b/source/connector-mobilizon/front/date-time-wrapper.js @@ -2,10 +2,7 @@ import { DateTime } from 'luxon' export default class DateTimeWrapper { - constructor({ locale, text, timeZone }) { - if (!timeZone) { - timeZone = 'utc' - } + constructor({ locale = 'en-GB', text, timeZone = 'utc' } = {}) { this.dateTime = DateTime.fromISO(text, { locale, zone: timeZone }) } diff --git a/source/connector-mobilizon/front/events-displayer-test.js b/source/connector-mobilizon/front/events-displayer-test.js index cac5358..fc1ff2b 100644 --- a/source/connector-mobilizon/front/events-displayer-test.js +++ b/source/connector-mobilizon/front/events-displayer-test.js @@ -13,6 +13,7 @@ test.beforeEach(t => { t.context.list = document.createElement('ul') t.context.list.setAttribute('data-locale', 'en-GB') t.context.list.setAttribute('data-maximum', '2') + t.context.list.setAttribute('data-time-zone', 'utc') const listElement = document.createElement('li') listElement.setAttribute('style', 'display: none;') t.context.list.appendChild(listElement) diff --git a/source/connector-mobilizon/front/formatter-test.js b/source/connector-mobilizon/front/formatter-test.js index 90da46e..72cd424 100644 --- a/source/connector-mobilizon/front/formatter-test.js +++ b/source/connector-mobilizon/front/formatter-test.js @@ -2,12 +2,12 @@ import test from 'ava' import Formatter from './formatter' test('#formatDate one date', t => { - const date = Formatter.formatDate({ locale: 'en-GB', start: '2021-04-15T10:30:00Z', end: '2021-04-15T15:30:00Z' }) + const date = Formatter.formatDate({ start: '2021-04-15T10:30:00Z', end: '2021-04-15T15:30:00Z' }) t.is(date, '15/04/2021 10:30 - 15:30') }) test('#formatDate two dates', t => { - const date = Formatter.formatDate({ locale: 'en-GB', start: '2021-04-15T10:30:00Z', end: '2021-04-16T15:30:00Z' }) + const date = Formatter.formatDate({ start: '2021-04-15T10:30:00Z', end: '2021-04-16T15:30:00Z' }) t.is(date, '15/04/2021 10:30 - 16/04/2021 15:30') })