2021-04-04 18:03:05 +02:00
|
|
|
import { DateTime } 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
|
|
|
|
}
|
2021-01-15 20:30:05 +01:00
|
|
|
|
|
|
|
static getCurrentDatetimeAsString() {
|
2021-04-04 18:03:05 +02:00
|
|
|
return DateTime.local().toString()
|
2021-01-15 20:30:05 +01:00
|
|
|
}
|
2021-01-08 14:08:40 +01:00
|
|
|
}
|