Skip to content

Commit aebc22c

Browse files
committed
Revert "fix(timezone): convert dates to UTC"
This reverts commit b90280f.
1 parent b90280f commit aebc22c

2 files changed

Lines changed: 1 addition & 27 deletions

File tree

src/calendar.mjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import ical from 'ical';
22

3-
import { toUTC } from './utils/dates.mjs';
4-
53
/**
64
* Creates an ICAL instance from the input URL
75
* @param {string} url
@@ -48,7 +46,7 @@ export const findNextMeetingDate = async (allEvents, { properties }) => {
4846
const duringOurTimeframe = event.rrule.between(weekStart, weekEnd);
4947

5048
if (duringOurTimeframe.length > 0) {
51-
return toUTC(event.tzid, duringOurTimeframe[0]);
49+
return duringOurTimeframe[0];
5250
}
5351
}
5452

src/utils/dates.mjs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,5 @@
11
import { RELEVANT_TIMEZONES } from '../constants.mjs';
22

3-
/**
4-
* Converts a zoned date into UTC
5-
* @param {string} timeZone
6-
* @param {Date} date
7-
*/
8-
export const toUTC = (timeZone, date = new Date()) => {
9-
const formatter = new Intl.DateTimeFormat('en-US', {
10-
timeZone,
11-
timeZoneName: 'shortOffset',
12-
});
13-
14-
const parts = formatter.formatToParts(date);
15-
const tzPart = parts.find(p => p.type === 'timeZoneName');
16-
const match = tzPart?.value.match(/GMT([+-]\d{1,2})(?::(\d{2}))?/);
17-
18-
if (!match) {
19-
return date;
20-
}
21-
22-
const hours = parseInt(match[1], 10);
23-
24-
return new Date(date.getTime() + hours * 60 * 60 * 1000);
25-
};
26-
273
/**
284
* Generic datetime formatter that accepts DateTimeFormat options
295
* @param {Date} date - The date to format

0 commit comments

Comments
 (0)