1
0
mirror of https://github.com/dwaxweiler/connector-mobilizon synced 2025-06-05 21:59:25 +02:00

extract two methods from main file

This commit is contained in:
Daniel Waxweiler
2021-04-13 21:10:28 +02:00
parent cf49fb47d6
commit 72f2c12343
3 changed files with 65 additions and 21 deletions

View File

@@ -0,0 +1,31 @@
import DateTimeWrapper from './date-time-wrapper'
export default class Formatter {
static formatDate({ start, end }) {
const startDateTime = new DateTimeWrapper(start)
const endDateTime = new DateTimeWrapper(end)
let dateText = startDateTime.getShortDate()
dateText += ' ' + startDateTime.get24Time()
dateText += ' - '
if (!startDateTime.equalsDate(endDateTime)) {
dateText += endDateTime.getShortDate() + ' '
}
dateText += endDateTime.get24Time()
return dateText
}
static formatLocation({ description, locality }) {
let location = ''
if (description) {
location += description
}
if (location && locality) {
location += ', '
}
if (locality) {
location += locality
}
return location
}
}