mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
timezone offset in migration 1 hour, check event date string for ISO format
This commit is contained in:
parent
fe3e5dc483
commit
44d6f31574
@ -19,11 +19,11 @@ export async function up(next) {
|
||||
for (const event of events.records) {
|
||||
let [id, eventStart, eventEnd] = event
|
||||
let date = new Date(eventStart)
|
||||
date.setHours(date.getHours() - 2)
|
||||
date.setHours(date.getHours() - 1)
|
||||
eventStart = date.toISOString()
|
||||
if (eventEnd) {
|
||||
date = new Date(eventEnd)
|
||||
date.setHours(date.getHours() - 2)
|
||||
date.setHours(date.getHours() - 1)
|
||||
eventEnd = date.toISOString()
|
||||
}
|
||||
await transaction.run(`
|
||||
|
||||
@ -34,6 +34,8 @@ const validateEventDate = (dateString) => {
|
||||
const date = new Date(dateString)
|
||||
if (date.toString() === 'Invalid Date')
|
||||
throw new UserInputError('Event start date must be a valid date!')
|
||||
if (date.toISOString() !== dateString)
|
||||
throw new UserInputError('Event start date must be in ISO format!')
|
||||
const now = new Date()
|
||||
if (date.getTime() < now.getTime()) {
|
||||
throw new UserInputError('Event start date must be in the future!')
|
||||
@ -44,6 +46,8 @@ const validateEventEnd = (start, end) => {
|
||||
const endDate = new Date(end)
|
||||
if (endDate.toString() === 'Invalid Date')
|
||||
throw new UserInputError('Event end date must be a valid date!')
|
||||
if (endDate.toISOString() !== end)
|
||||
throw new UserInputError('Event end date must be in ISO format!')
|
||||
const startDate = new Date(start)
|
||||
if (endDate < startDate)
|
||||
throw new UserInputError('Event end date must be a after event start date!')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user