refactor: v2 bookings allow non UTC start time
Problem
Users need to convert start time to UTC when making a booking.
Solution
If time with timezone is submitted, then convert to UTC automatically.
can I work on this issue
Hey @Tosifkankod , I've already worked on this. I'll push it in sometime.
ok
Hi Team,
Could you please clarify the following regarding the expected format for the start time in the request body?
- Is it mandatory for users to provide the start time in ISO 8601 format? If yes, please confirm whether the following Approach 1 is the correct way to handle it:
Input body example:
{
"start": "2025-06-19T09:30:00Z",
"attendee": {
"name": "Free",
"email": "[email protected]",
"timeZone": "Asia/Kolkata",
"phoneNumber": "+919876543210",
"language": "it"
},
"bookingFieldsResponses": { "customField": "customValue" },
"eventTypeId": 9,
"eventTypeSlug": "daily",
"username": "john-doe",
"location": "integrations:daily",
"metadata": { "key": "null" }
}
Approach 1 (If ISO format is required)
let start = '2025-06-19T15:00:00+05:30';
const timeZone = inputBooking.attendee?.timeZone;
if (!start.endsWith('Z')) {
const dt = DateTime.fromISO(start, { zone: 'utc' });
}
Approach 2 (If ISO format is not mandatory)
Since the user provides a timeZone in the attendee object, we can use it to convert the given start time to UTC if it's not already in ISO format:
const inputFormat = "MM/dd/yyyy hh:mm a";
const userInput = "06/26/2000 10:00 AM";
const dt = DateTime.fromFormat(userInput, inputFormat, { zone: 'Asia/Kolkata' });
if (dt.isValid) {
const utcTime = dt.toUTC().toISO();
console.log("Converted UTC Time:", utcTime);
} else {
console.error("Invalid date-time input");
}
Current Implementation FYR
DateTime.fromISO(inputBooking.start, { zone: "utc" }).setZone(
inputBooking.attendee.timeZone
);
Thank you!
@PeerRich @CarinaWolli @retrogtx @hariombalhara