mirror of
https://github.com/dwaxweiler/connector-mobilizon
synced 2025-06-05 21:59:25 +02:00
localise dates
This commit is contained in:
@ -1,47 +1,43 @@
|
||||
import test from 'ava'
|
||||
import DateTimeWrapper from './date-time-wrapper'
|
||||
|
||||
test.before(() => {
|
||||
DateTimeWrapper.setDefaultLocale('en-GB')
|
||||
})
|
||||
|
||||
test('#getShortDate usual date', t => {
|
||||
const d = new DateTimeWrapper('2020-12-24T16:45:00Z')
|
||||
const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' })
|
||||
t.is(d.getShortDate(), '24/12/2020')
|
||||
})
|
||||
|
||||
test('#get24Time usual time', t => {
|
||||
const d = new DateTimeWrapper('2020-12-24T16:45:00Z')
|
||||
t.is(d.get24Time(), '17:45')
|
||||
const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' })
|
||||
t.is(d.get24Time(), '17:45')
|
||||
})
|
||||
|
||||
test('#equalsDate same date, different time', t => {
|
||||
const d = new DateTimeWrapper('2020-12-24T16:45:00Z')
|
||||
const e = new DateTimeWrapper('2020-12-24T17:46:01Z')
|
||||
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' })
|
||||
t.true(d.equalsDate(e))
|
||||
})
|
||||
|
||||
test('#equalsDate different date, different time', t => {
|
||||
const d = new DateTimeWrapper('2020-12-24T16:45:00Z')
|
||||
const e = new DateTimeWrapper('2021-11-25T17:46:01Z')
|
||||
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' })
|
||||
t.false(d.equalsDate(e))
|
||||
})
|
||||
|
||||
test('#equalsDate different day, different time', t => {
|
||||
const d = new DateTimeWrapper('2020-12-24T16:45:00Z')
|
||||
const e = new DateTimeWrapper('2020-12-25T17:46:01Z')
|
||||
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' })
|
||||
t.false(d.equalsDate(e))
|
||||
})
|
||||
|
||||
test('#equalsDate different month, different time', t => {
|
||||
const d = new DateTimeWrapper('2020-12-24T16:45:00Z')
|
||||
const e = new DateTimeWrapper('2020-11-24T17:46:01Z')
|
||||
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' })
|
||||
t.false(d.equalsDate(e))
|
||||
})
|
||||
|
||||
test('#equalsDate different year, different time', t => {
|
||||
const d = new DateTimeWrapper('2020-12-24T16:45:00Z')
|
||||
const e = new DateTimeWrapper('2021-12-24T17:46:01Z')
|
||||
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' })
|
||||
t.false(d.equalsDate(e))
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user