-
-
Notifications
You must be signed in to change notification settings - Fork 270
🐛 Bug: Incorrect Times/Timezones when fetching events from the Community calendar #1036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
🐛 Bug
Indicates that the issue is a bug or defect.
Hacktoberfest
Issues accepeted Hacktoberfest'24
Status: In Progress
This issue is being worked on, and has someone assigned.
Comments
Let me try fixing this |
@benjagm May I work on this issue ,,, |
Thanks, @techmannih. please go ahead. The only comments is we need the meetings to be shown in the website converted to UTC for all visitors. |
@benjagm please check this, this is not depend on localtime, function printEventsForNextWeeks(icalData: { [x: string]: any }) {
const arrayDates = [];
if (!icalData) {
console.error('iCal data is empty or invalid.');
return;
}
// Calculate the range of dates for the next 12 weeks from today
const today = moment.utc().startOf('day'); // Use UTC for today
const nextFourWeeksEnd = moment.utc().add(12, 'weeks').endOf('day'); // Use UTC for the end date
// Loop through the events in the iCal data
for (const k in icalData) {
const event = icalData[k];
if (event.type === 'VEVENT') {
const title = event.summary;
// Parse the start date in UTC
const startDate = moment.utc(event.start);
console.log('startDate', startDate);
// Complicated case - if an RRULE exists, handle multiple recurrences of the event
if (event.rrule) {
const dates = event.rrule.between(today.toDate(), nextFourWeeksEnd.toDate(), true);
// Loop through the set of date entries
for (const date of dates) {
const startDate = moment.utc(date); // Use UTC directly
// Check if the event falls within the next 12 weeks
if (startDate.isBetween(today, nextFourWeeksEnd, undefined, '[]')) {
const utcDate = startDate.utc(); // Already in UTC
const time = utcDate.format('MMMM Do YYYY, h:mm a');
const day = utcDate.format('D');
const parsedStartDate = utcDate.format('YYYY-MM-DD HH:mm:ss');
arrayDates.push({
title,
time,
day,
timezone: 'UTC',
parsedStartDate,
});
}
}
} else {
// Simple case - no recurrences
if (startDate.isBetween(today, nextFourWeeksEnd, undefined, '[]')) {
const utcDate = startDate; // Already in UTC
const time = utcDate.format('MMMM Do YYYY, h:mm a');
const day = utcDate.format('D');
const parsedStartDate = utcDate.format('YYYY-MM-DD HH:mm:ss');
arrayDates.push({
title,
time,
day,
timezone: 'UTC',
parsedStartDate,
});
}
}
}
}
// Sort the array based on parsedStartDate
arrayDates.sort((x, y) => new Date(x.parsedStartDate).getTime() - new Date(y.parsedStartDate).getTime());
return arrayDates;
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
🐛 Bug
Indicates that the issue is a bug or defect.
Hacktoberfest
Issues accepeted Hacktoberfest'24
Status: In Progress
This issue is being worked on, and has someone assigned.
Describe the bug
We are fetching events from the JSON Schema's Google Calendar using the ical file and events are in different timezones. To present it on the Landing page and the Community page we are converting all to UTC timezone but it seems that the conversion is not working as expected. Specifically the APAC/Americas bi-monthly office hours. We need to review the logic of Timezone conversion to make sure it works.
Steps To Reproduce
Access the landing page or the community page and check the events list. The time/timezone should be consistent with the event present in the calendar:
https://calendar.google.com/calendar/embed?src=json.schema.community%40gmail.com&ctz=Europe%2FLondon
Expected Behavior
Correct times are presented converting to UTC
Screenshots
No response
Device Information [optional]
Are you working on this issue?
No
Do you think this work might require an [Architectural Decision Record (ADR)]? (significant or noteworthy)
No
The text was updated successfully, but these errors were encountered: