ical-generator 11.1.4-develop.4 → 11.1.4-develop.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -141,5 +141,5 @@
141
141
  "test": "mocha"
142
142
  },
143
143
  "type": "module",
144
- "version": "11.1.4-develop.4"
144
+ "version": "11.1.4-develop.5"
145
145
  }
package/src/tools.ts CHANGED
@@ -296,7 +296,14 @@ export function formatDate(
296
296
  if (typeof d === 'string' || d instanceof Date) {
297
297
  // TZDate is an extension of the native Date object.
298
298
  // @see https://github.com/date-fns/tz for more information.
299
- const m = isTZDate(d) ? d.withTimeZone(timezone) : new Date(d);
299
+ // All-day dates of a TZDate with its own time zone use that zone,
300
+ // same as for moment-timezone and Luxon objects (see #592)
301
+ const ownZone = dateonly && !timezone && isTZDate(d) && !!d.timeZone;
302
+ const m = ownZone
303
+ ? d
304
+ : isTZDate(d)
305
+ ? d.withTimeZone(timezone)
306
+ : new Date(d);
300
307
 
301
308
  // (!dateonly && !floating) || !timezone => utc
302
309
  let s =
@@ -305,7 +312,7 @@ export function formatDate(
305
312
  m.getUTCDate().toString().padStart(2, '0');
306
313
 
307
314
  // (dateonly || floating) && timezone => tz
308
- if (timezone) {
315
+ if (timezone || ownZone) {
309
316
  s =
310
317
  m.getFullYear().toString().padStart(4, '0') +
311
318
  String(m.getMonth() + 1).padStart(2, '0') +
@@ -370,7 +377,8 @@ export function formatDate(
370
377
  if (timezone) {
371
378
  t = d.withTimeZone(timezone);
372
379
  }
373
- if (!timezone && d.timeZoneId !== 'UTC') {
380
+ // all-day dates keep the object's own time zone (see #592)
381
+ if (!timezone && !dateonly && d.timeZoneId !== 'UTC') {
374
382
  t = d.withTimeZone('UTC');
375
383
  }
376
384