Adding formatting of date when reading from email
This commit is contained in:
parent
5a90d16872
commit
54aef1ece8
2 changed files with 13 additions and 3 deletions
|
|
@ -1,13 +1,15 @@
|
|||
import 'dayjs/locale/nl'
|
||||
|
||||
import * as dayjs from 'dayjs'
|
||||
import * as customParseFormat from 'dayjs/plugin/customParseFormat'
|
||||
import * as isSameOrBefore from 'dayjs/plugin/isSameOrBefore'
|
||||
import * as timezone from 'dayjs/plugin/timezone'
|
||||
import * as utc from 'dayjs/plugin/utc'
|
||||
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(isSameOrBefore)
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(utc)
|
||||
dayjs.locale('nl')
|
||||
|
||||
dayjs.tz.setDefault('Europe/Amsterdam')
|
||||
|
|
@ -32,8 +34,9 @@ export const convertDateRangeStringToObject = ({
|
|||
|
||||
const dayjsTz = (
|
||||
date?: string | number | Date | dayjs.Dayjs | null | undefined,
|
||||
format?: string,
|
||||
) => {
|
||||
return dayjs(date).tz()
|
||||
return dayjs(date, format).tz()
|
||||
}
|
||||
|
||||
export default dayjsTz
|
||||
|
|
|
|||
|
|
@ -64,7 +64,14 @@ export class WaitingListService {
|
|||
|
||||
private async handleWaitingListEmail(email: Email) {
|
||||
const { date, startTime } = this.getWaitingListDetails(email)
|
||||
const dateRangeStart = dayjs(`${date} ${startTime}`)
|
||||
const dateRangeStart = dayjs(`${date} ${startTime}`, 'YYYY-MM-DD HH:mm')
|
||||
if (!dateRangeStart.isValid()) {
|
||||
this.loggerService.error('Invalid date parsed from email', {
|
||||
date,
|
||||
startTime,
|
||||
})
|
||||
return
|
||||
}
|
||||
const reservations = await this.reservationsService.getByDateOnWaitingList(
|
||||
dateRangeStart,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue