connector-wordpress/source/connector-mobilizon/front/date-time-wrapper.js

33 lines
717 B
JavaScript
Raw Normal View History

2021-05-04 10:37:30 +02:00
import { DateTime, Settings } from 'luxon'
2021-01-08 14:08:40 +01:00
2021-04-13 20:50:56 +02:00
export default class DateTimeWrapper {
2021-01-08 14:08:40 +01:00
constructor(text) {
this.dateTime = DateTime.fromISO(text)
}
getShortDate() {
return this.dateTime.toLocaleString(DateTime.DATE_SHORT)
}
get24Time() {
return this.dateTime.toLocaleString(DateTime.TIME_24_SIMPLE)
}
equalsDate(other) {
return this.dateTime &&
other.dateTime &&
this.dateTime.day === other.dateTime.day &&
this.dateTime.month === other.dateTime.month &&
this.dateTime.year === other.dateTime.year
}
static getCurrentDatetimeAsString() {
2021-05-04 10:37:30 +02:00
return DateTime.now().toString()
}
static setDefaultLocale(locale) {
Settings.defaultLocale = locale
}
2021-01-08 14:08:40 +01:00
}