add-to-calendar-button 2.12.9 → 2.12.10

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.
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: 3D
7
7
  *
8
- * Version: 2.12.9
8
+ * Version: 2.12.10
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Date
7
7
  *
8
- * Version: 2.12.9
8
+ * Version: 2.12.10
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Flat
7
7
  *
8
- * Version: 2.12.9
8
+ * Version: 2.12.10
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Neumorphism
7
7
  *
8
- * Version: 2.12.9
8
+ * Version: 2.12.10
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Round
7
7
  *
8
- * Version: 2.12.9
8
+ * Version: 2.12.10
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Simple
7
7
  *
8
- * Version: 2.12.9
8
+ * Version: 2.12.10
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Text
7
7
  *
8
- * Version: 2.12.9
8
+ * Version: 2.12.10
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Default
7
7
  *
8
- * Version: 2.12.9
8
+ * Version: 2.12.10
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -223,14 +223,14 @@ function tzlib_get_timezones(jsonType = false) {
223
223
  * Add to Calendar Button
224
224
  * ++++++++++++++++++++++
225
225
  *
226
- * Version: 2.12.9
226
+ * Version: 2.12.10
227
227
  * Creator: Jens Kuerschner (https://jekuer.com)
228
228
  * Project: https://github.com/add2cal/add-to-calendar-button
229
229
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
230
230
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
231
231
  *
232
232
  */
233
- const atcbVersion = '2.12.9';
233
+ const atcbVersion = '2.12.10';
234
234
  const atcbCssTemplate = {};
235
235
  const atcbIsBrowser = () => {
236
236
  if (typeof window === 'undefined') {
@@ -595,9 +595,10 @@ function atcb_decorate_data_rrule(data) {
595
595
  function atcb_decorate_data_recurring_events(data) {
596
596
  const startDate = data.dates?.[0].startDate || data.startDate;
597
597
  const startTime = data.dates?.[0].startTime || data.startTime;
598
+ const tzid = data.dates?.[0].timeZone || data.timeZone || 'UTC';
599
+ const offset = startTime && startTime !== '' ? tzlib_get_offset(tzid, startDate, startTime) : '';
598
600
  const startDateTime = (function () {
599
601
  if (startTime && startTime !== '') {
600
- const offset = tzlib_get_offset(data.dates?.[0].timeZone || data.timeZone, startDate, startTime);
601
602
  return new Date(startDate + ' ' + startTime + ':00 GMT' + offset);
602
603
  }
603
604
  return new Date(startDate + 'T00:00:00Z');
@@ -607,31 +608,28 @@ function atcb_decorate_data_recurring_events(data) {
607
608
  if (!occurenceData || !occurenceData.nextOccurrence) {
608
609
  return data;
609
610
  }
610
- const nextOccurrence =
611
- String(occurenceData.nextOccurrence.getFullYear()) +
612
- '-' +
613
- String(occurenceData.nextOccurrence.getMonth() + 1).padStart(2, '0') +
614
- '-' +
615
- String(occurenceData.nextOccurrence.getDate()).padStart(2, '0') +
616
- (startTime && startTime !== '' ? 'T' + String(occurenceData.nextOccurrence.getHours()).padStart(2, '0') + ':' + String(occurenceData.nextOccurrence.getMinutes()).padStart(2, '0') : '');
617
- data.startDate = nextOccurrence.slice(0, 10);
611
+ function formatInTz(dateObj, timeZone, includeTime) {
612
+ const opts = includeTime ? { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' } : { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit' };
613
+ const parts = new Intl.DateTimeFormat('en-CA', opts).formatToParts(dateObj);
614
+ const get = (t) => parts.find((p) => p.type === t)?.value || '';
615
+ return {
616
+ date: `${get('year')}-${get('month')}-${get('day')}`,
617
+ time: includeTime ? `${get('hour')}:${get('minute')}` : '',
618
+ };
619
+ }
620
+ const nextLocal = formatInTz(occurenceData.nextOccurrence, tzid, !!(startTime && startTime !== ''));
621
+ data.startDate = nextLocal.date;
618
622
  if (startTime && startTime !== '') {
619
- data.startTime = nextOccurrence.slice(11, 16);
623
+ data.startTime = nextLocal.time;
620
624
  }
621
625
  const endDate = data.dates?.[0].endDate || data.endDate || startDate;
622
626
  const endTime = data.dates?.[0].endTime || data.endTime || '';
623
627
  const diff = new Date(endDate + (endTime && endTime !== '' ? 'T' + endTime : '')).getTime() - new Date(startDate + (startTime && startTime !== '' ? 'T' + startTime : '')).getTime();
624
628
  const newEndDateTime = new Date(occurenceData.nextOccurrence.getTime() + diff);
625
- const newEndDateTimeString =
626
- String(newEndDateTime.getFullYear()) +
627
- '-' +
628
- String(newEndDateTime.getMonth() + 1).padStart(2, '0') +
629
- '-' +
630
- String(newEndDateTime.getDate()).padStart(2, '0') +
631
- (endTime && endTime !== '' ? 'T' + String(newEndDateTime.getHours()).padStart(2, '0') + ':' + String(newEndDateTime.getMinutes()).padStart(2, '0') : '');
632
- data.endDate = newEndDateTimeString.slice(0, 10);
629
+ const nextEndLocal = formatInTz(newEndDateTime, tzid, !!(endTime && endTime !== ''));
630
+ data.endDate = nextEndLocal.date;
633
631
  if (endTime && endTime !== '') {
634
- data.endTime = newEndDateTimeString.slice(11, 16);
632
+ data.endTime = nextEndLocal.time;
635
633
  }
636
634
  if ((data.recurrence_count && data.recurrence_count !== '') || (data.recurrence_until && data.recurrence_until !== '')) {
637
635
  if (occurenceData.adjustedCount < 2) {
@@ -223,14 +223,14 @@ function tzlib_get_timezones(jsonType = false) {
223
223
  * Add to Calendar Button
224
224
  * ++++++++++++++++++++++
225
225
  *
226
- * Version: 2.12.9
226
+ * Version: 2.12.10
227
227
  * Creator: Jens Kuerschner (https://jekuer.com)
228
228
  * Project: https://github.com/add2cal/add-to-calendar-button
229
229
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
230
230
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
231
231
  *
232
232
  */
233
- const atcbVersion = '2.12.9';
233
+ const atcbVersion = '2.12.10';
234
234
  const atcbCssTemplate = {
235
235
  if (typeof window === 'undefined') {
236
236
  return false;
@@ -594,9 +594,10 @@ function atcb_decorate_data_rrule(data) {
594
594
  function atcb_decorate_data_recurring_events(data) {
595
595
  const startDate = data.dates?.[0].startDate || data.startDate;
596
596
  const startTime = data.dates?.[0].startTime || data.startTime;
597
+ const tzid = data.dates?.[0].timeZone || data.timeZone || 'UTC';
598
+ const offset = startTime && startTime !== '' ? tzlib_get_offset(tzid, startDate, startTime) : '';
597
599
  const startDateTime = (function () {
598
600
  if (startTime && startTime !== '') {
599
- const offset = tzlib_get_offset(data.dates?.[0].timeZone || data.timeZone, startDate, startTime);
600
601
  return new Date(startDate + ' ' + startTime + ':00 GMT' + offset);
601
602
  }
602
603
  return new Date(startDate + 'T00:00:00Z');
@@ -606,31 +607,28 @@ function atcb_decorate_data_recurring_events(data) {
606
607
  if (!occurenceData || !occurenceData.nextOccurrence) {
607
608
  return data;
608
609
  }
609
- const nextOccurrence =
610
- String(occurenceData.nextOccurrence.getFullYear()) +
611
- '-' +
612
- String(occurenceData.nextOccurrence.getMonth() + 1).padStart(2, '0') +
613
- '-' +
614
- String(occurenceData.nextOccurrence.getDate()).padStart(2, '0') +
615
- (startTime && startTime !== '' ? 'T' + String(occurenceData.nextOccurrence.getHours()).padStart(2, '0') + ':' + String(occurenceData.nextOccurrence.getMinutes()).padStart(2, '0') : '');
616
- data.startDate = nextOccurrence.slice(0, 10);
610
+ function formatInTz(dateObj, timeZone, includeTime) {
611
+ const opts = includeTime ? { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' } : { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit' };
612
+ const parts = new Intl.DateTimeFormat('en-CA', opts).formatToParts(dateObj);
613
+ const get = (t) => parts.find((p) => p.type === t)?.value || '';
614
+ return {
615
+ date: `${get('year')}-${get('month')}-${get('day')}`,
616
+ time: includeTime ? `${get('hour')}:${get('minute')}` : '',
617
+ };
618
+ }
619
+ const nextLocal = formatInTz(occurenceData.nextOccurrence, tzid, !!(startTime && startTime !== ''));
620
+ data.startDate = nextLocal.date;
617
621
  if (startTime && startTime !== '') {
618
- data.startTime = nextOccurrence.slice(11, 16);
622
+ data.startTime = nextLocal.time;
619
623
  }
620
624
  const endDate = data.dates?.[0].endDate || data.endDate || startDate;
621
625
  const endTime = data.dates?.[0].endTime || data.endTime || '';
622
626
  const diff = new Date(endDate + (endTime && endTime !== '' ? 'T' + endTime : '')).getTime() - new Date(startDate + (startTime && startTime !== '' ? 'T' + startTime : '')).getTime();
623
627
  const newEndDateTime = new Date(occurenceData.nextOccurrence.getTime() + diff);
624
- const newEndDateTimeString =
625
- String(newEndDateTime.getFullYear()) +
626
- '-' +
627
- String(newEndDateTime.getMonth() + 1).padStart(2, '0') +
628
- '-' +
629
- String(newEndDateTime.getDate()).padStart(2, '0') +
630
- (endTime && endTime !== '' ? 'T' + String(newEndDateTime.getHours()).padStart(2, '0') + ':' + String(newEndDateTime.getMinutes()).padStart(2, '0') : '');
631
- data.endDate = newEndDateTimeString.slice(0, 10);
628
+ const nextEndLocal = formatInTz(newEndDateTime, tzid, !!(endTime && endTime !== ''));
629
+ data.endDate = nextEndLocal.date;
632
630
  if (endTime && endTime !== '') {
633
- data.endTime = newEndDateTimeString.slice(11, 16);
631
+ data.endTime = nextEndLocal.time;
634
632
  }
635
633
  if ((data.recurrence_count && data.recurrence_count !== '') || (data.recurrence_until && data.recurrence_until !== '')) {
636
634
  if (occurenceData.adjustedCount < 2) {
@@ -223,14 +223,14 @@ function tzlib_get_timezones(jsonType = false) {
223
223
  * Add to Calendar Button
224
224
  * ++++++++++++++++++++++
225
225
  *
226
- * Version: 2.12.9
226
+ * Version: 2.12.10
227
227
  * Creator: Jens Kuerschner (https://jekuer.com)
228
228
  * Project: https://github.com/add2cal/add-to-calendar-button
229
229
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
230
230
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
231
231
  *
232
232
  */
233
- const atcbVersion = '2.12.9';
233
+ const atcbVersion = '2.12.10';
234
234
  const atcbCssTemplate = {};
235
235
  const atcbIsBrowser = () => {
236
236
  if (typeof window === 'undefined') {
@@ -595,9 +595,10 @@ function atcb_decorate_data_rrule(data) {
595
595
  function atcb_decorate_data_recurring_events(data) {
596
596
  const startDate = data.dates?.[0].startDate || data.startDate;
597
597
  const startTime = data.dates?.[0].startTime || data.startTime;
598
+ const tzid = data.dates?.[0].timeZone || data.timeZone || 'UTC';
599
+ const offset = startTime && startTime !== '' ? tzlib_get_offset(tzid, startDate, startTime) : '';
598
600
  const startDateTime = (function () {
599
601
  if (startTime && startTime !== '') {
600
- const offset = tzlib_get_offset(data.dates?.[0].timeZone || data.timeZone, startDate, startTime);
601
602
  return new Date(startDate + ' ' + startTime + ':00 GMT' + offset);
602
603
  }
603
604
  return new Date(startDate + 'T00:00:00Z');
@@ -607,31 +608,28 @@ function atcb_decorate_data_recurring_events(data) {
607
608
  if (!occurenceData || !occurenceData.nextOccurrence) {
608
609
  return data;
609
610
  }
610
- const nextOccurrence =
611
- String(occurenceData.nextOccurrence.getFullYear()) +
612
- '-' +
613
- String(occurenceData.nextOccurrence.getMonth() + 1).padStart(2, '0') +
614
- '-' +
615
- String(occurenceData.nextOccurrence.getDate()).padStart(2, '0') +
616
- (startTime && startTime !== '' ? 'T' + String(occurenceData.nextOccurrence.getHours()).padStart(2, '0') + ':' + String(occurenceData.nextOccurrence.getMinutes()).padStart(2, '0') : '');
617
- data.startDate = nextOccurrence.slice(0, 10);
611
+ function formatInTz(dateObj, timeZone, includeTime) {
612
+ const opts = includeTime ? { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' } : { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit' };
613
+ const parts = new Intl.DateTimeFormat('en-CA', opts).formatToParts(dateObj);
614
+ const get = (t) => parts.find((p) => p.type === t)?.value || '';
615
+ return {
616
+ date: `${get('year')}-${get('month')}-${get('day')}`,
617
+ time: includeTime ? `${get('hour')}:${get('minute')}` : '',
618
+ };
619
+ }
620
+ const nextLocal = formatInTz(occurenceData.nextOccurrence, tzid, !!(startTime && startTime !== ''));
621
+ data.startDate = nextLocal.date;
618
622
  if (startTime && startTime !== '') {
619
- data.startTime = nextOccurrence.slice(11, 16);
623
+ data.startTime = nextLocal.time;
620
624
  }
621
625
  const endDate = data.dates?.[0].endDate || data.endDate || startDate;
622
626
  const endTime = data.dates?.[0].endTime || data.endTime || '';
623
627
  const diff = new Date(endDate + (endTime && endTime !== '' ? 'T' + endTime : '')).getTime() - new Date(startDate + (startTime && startTime !== '' ? 'T' + startTime : '')).getTime();
624
628
  const newEndDateTime = new Date(occurenceData.nextOccurrence.getTime() + diff);
625
- const newEndDateTimeString =
626
- String(newEndDateTime.getFullYear()) +
627
- '-' +
628
- String(newEndDateTime.getMonth() + 1).padStart(2, '0') +
629
- '-' +
630
- String(newEndDateTime.getDate()).padStart(2, '0') +
631
- (endTime && endTime !== '' ? 'T' + String(newEndDateTime.getHours()).padStart(2, '0') + ':' + String(newEndDateTime.getMinutes()).padStart(2, '0') : '');
632
- data.endDate = newEndDateTimeString.slice(0, 10);
629
+ const nextEndLocal = formatInTz(newEndDateTime, tzid, !!(endTime && endTime !== ''));
630
+ data.endDate = nextEndLocal.date;
633
631
  if (endTime && endTime !== '') {
634
- data.endTime = newEndDateTimeString.slice(11, 16);
632
+ data.endTime = nextEndLocal.time;
635
633
  }
636
634
  if ((data.recurrence_count && data.recurrence_count !== '') || (data.recurrence_until && data.recurrence_until !== '')) {
637
635
  if (occurenceData.adjustedCount < 2) {
package/dist/atcb.js CHANGED
@@ -223,14 +223,14 @@ function tzlib_get_timezones(jsonType = false) {
223
223
  * Add to Calendar Button
224
224
  * ++++++++++++++++++++++
225
225
  *
226
- * Version: 2.12.9
226
+ * Version: 2.12.10
227
227
  * Creator: Jens Kuerschner (https://jekuer.com)
228
228
  * Project: https://github.com/add2cal/add-to-calendar-button
229
229
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
230
230
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
231
231
  *
232
232
  */
233
- const atcbVersion = '2.12.9';
233
+ const atcbVersion = '2.12.10';
234
234
  const atcbCssTemplate = {
235
235
  if (typeof window === 'undefined') {
236
236
  return false;
@@ -594,9 +594,10 @@ function atcb_decorate_data_rrule(data) {
594
594
  function atcb_decorate_data_recurring_events(data) {
595
595
  const startDate = data.dates?.[0].startDate || data.startDate;
596
596
  const startTime = data.dates?.[0].startTime || data.startTime;
597
+ const tzid = data.dates?.[0].timeZone || data.timeZone || 'UTC';
598
+ const offset = startTime && startTime !== '' ? tzlib_get_offset(tzid, startDate, startTime) : '';
597
599
  const startDateTime = (function () {
598
600
  if (startTime && startTime !== '') {
599
- const offset = tzlib_get_offset(data.dates?.[0].timeZone || data.timeZone, startDate, startTime);
600
601
  return new Date(startDate + ' ' + startTime + ':00 GMT' + offset);
601
602
  }
602
603
  return new Date(startDate + 'T00:00:00Z');
@@ -606,31 +607,28 @@ function atcb_decorate_data_recurring_events(data) {
606
607
  if (!occurenceData || !occurenceData.nextOccurrence) {
607
608
  return data;
608
609
  }
609
- const nextOccurrence =
610
- String(occurenceData.nextOccurrence.getFullYear()) +
611
- '-' +
612
- String(occurenceData.nextOccurrence.getMonth() + 1).padStart(2, '0') +
613
- '-' +
614
- String(occurenceData.nextOccurrence.getDate()).padStart(2, '0') +
615
- (startTime && startTime !== '' ? 'T' + String(occurenceData.nextOccurrence.getHours()).padStart(2, '0') + ':' + String(occurenceData.nextOccurrence.getMinutes()).padStart(2, '0') : '');
616
- data.startDate = nextOccurrence.slice(0, 10);
610
+ function formatInTz(dateObj, timeZone, includeTime) {
611
+ const opts = includeTime ? { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' } : { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit' };
612
+ const parts = new Intl.DateTimeFormat('en-CA', opts).formatToParts(dateObj);
613
+ const get = (t) => parts.find((p) => p.type === t)?.value || '';
614
+ return {
615
+ date: `${get('year')}-${get('month')}-${get('day')}`,
616
+ time: includeTime ? `${get('hour')}:${get('minute')}` : '',
617
+ };
618
+ }
619
+ const nextLocal = formatInTz(occurenceData.nextOccurrence, tzid, !!(startTime && startTime !== ''));
620
+ data.startDate = nextLocal.date;
617
621
  if (startTime && startTime !== '') {
618
- data.startTime = nextOccurrence.slice(11, 16);
622
+ data.startTime = nextLocal.time;
619
623
  }
620
624
  const endDate = data.dates?.[0].endDate || data.endDate || startDate;
621
625
  const endTime = data.dates?.[0].endTime || data.endTime || '';
622
626
  const diff = new Date(endDate + (endTime && endTime !== '' ? 'T' + endTime : '')).getTime() - new Date(startDate + (startTime && startTime !== '' ? 'T' + startTime : '')).getTime();
623
627
  const newEndDateTime = new Date(occurenceData.nextOccurrence.getTime() + diff);
624
- const newEndDateTimeString =
625
- String(newEndDateTime.getFullYear()) +
626
- '-' +
627
- String(newEndDateTime.getMonth() + 1).padStart(2, '0') +
628
- '-' +
629
- String(newEndDateTime.getDate()).padStart(2, '0') +
630
- (endTime && endTime !== '' ? 'T' + String(newEndDateTime.getHours()).padStart(2, '0') + ':' + String(newEndDateTime.getMinutes()).padStart(2, '0') : '');
631
- data.endDate = newEndDateTimeString.slice(0, 10);
628
+ const nextEndLocal = formatInTz(newEndDateTime, tzid, !!(endTime && endTime !== ''));
629
+ data.endDate = nextEndLocal.date;
632
630
  if (endTime && endTime !== '') {
633
- data.endTime = newEndDateTimeString.slice(11, 16);
631
+ data.endTime = nextEndLocal.time;
634
632
  }
635
633
  if ((data.recurrence_count && data.recurrence_count !== '') || (data.recurrence_until && data.recurrence_until !== '')) {
636
634
  if (occurenceData.adjustedCount < 2) {
@@ -6,14 +6,14 @@ const tzlibActions = require('timezones-ical-library');
6
6
  * Add to Calendar Button
7
7
  * ++++++++++++++++++++++
8
8
  *
9
- * Version: 2.12.9
9
+ * Version: 2.12.10
10
10
  * Creator: Jens Kuerschner (https://jekuer.com)
11
11
  * Project: https://github.com/add2cal/add-to-calendar-button
12
12
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
13
13
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
14
14
  *
15
15
  */
16
- const atcbVersion = '2.12.9';
16
+ const atcbVersion = '2.12.10';
17
17
  const atcbCssTemplate = {
18
18
  if (typeof window === 'undefined') {
19
19
  return false;
@@ -377,9 +377,10 @@ function atcb_decorate_data_rrule(data) {
377
377
  function atcb_decorate_data_recurring_events(data) {
378
378
  const startDate = data.dates?.[0].startDate || data.startDate;
379
379
  const startTime = data.dates?.[0].startTime || data.startTime;
380
+ const tzid = data.dates?.[0].timeZone || data.timeZone || 'UTC';
381
+ const offset = startTime && startTime !== '' ? tzlibActions.tzlib_get_offset(tzid, startDate, startTime) : '';
380
382
  const startDateTime = (function () {
381
383
  if (startTime && startTime !== '') {
382
- const offset = tzlibActions.tzlib_get_offset(data.dates?.[0].timeZone || data.timeZone, startDate, startTime);
383
384
  return new Date(startDate + ' ' + startTime + ':00 GMT' + offset);
384
385
  }
385
386
  return new Date(startDate + 'T00:00:00Z');
@@ -389,31 +390,28 @@ function atcb_decorate_data_recurring_events(data) {
389
390
  if (!occurenceData || !occurenceData.nextOccurrence) {
390
391
  return data;
391
392
  }
392
- const nextOccurrence =
393
- String(occurenceData.nextOccurrence.getFullYear()) +
394
- '-' +
395
- String(occurenceData.nextOccurrence.getMonth() + 1).padStart(2, '0') +
396
- '-' +
397
- String(occurenceData.nextOccurrence.getDate()).padStart(2, '0') +
398
- (startTime && startTime !== '' ? 'T' + String(occurenceData.nextOccurrence.getHours()).padStart(2, '0') + ':' + String(occurenceData.nextOccurrence.getMinutes()).padStart(2, '0') : '');
399
- data.startDate = nextOccurrence.slice(0, 10);
393
+ function formatInTz(dateObj, timeZone, includeTime) {
394
+ const opts = includeTime ? { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' } : { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit' };
395
+ const parts = new Intl.DateTimeFormat('en-CA', opts).formatToParts(dateObj);
396
+ const get = (t) => parts.find((p) => p.type === t)?.value || '';
397
+ return {
398
+ date: `${get('year')}-${get('month')}-${get('day')}`,
399
+ time: includeTime ? `${get('hour')}:${get('minute')}` : '',
400
+ };
401
+ }
402
+ const nextLocal = formatInTz(occurenceData.nextOccurrence, tzid, !!(startTime && startTime !== ''));
403
+ data.startDate = nextLocal.date;
400
404
  if (startTime && startTime !== '') {
401
- data.startTime = nextOccurrence.slice(11, 16);
405
+ data.startTime = nextLocal.time;
402
406
  }
403
407
  const endDate = data.dates?.[0].endDate || data.endDate || startDate;
404
408
  const endTime = data.dates?.[0].endTime || data.endTime || '';
405
409
  const diff = new Date(endDate + (endTime && endTime !== '' ? 'T' + endTime : '')).getTime() - new Date(startDate + (startTime && startTime !== '' ? 'T' + startTime : '')).getTime();
406
410
  const newEndDateTime = new Date(occurenceData.nextOccurrence.getTime() + diff);
407
- const newEndDateTimeString =
408
- String(newEndDateTime.getFullYear()) +
409
- '-' +
410
- String(newEndDateTime.getMonth() + 1).padStart(2, '0') +
411
- '-' +
412
- String(newEndDateTime.getDate()).padStart(2, '0') +
413
- (endTime && endTime !== '' ? 'T' + String(newEndDateTime.getHours()).padStart(2, '0') + ':' + String(newEndDateTime.getMinutes()).padStart(2, '0') : '');
414
- data.endDate = newEndDateTimeString.slice(0, 10);
411
+ const nextEndLocal = formatInTz(newEndDateTime, tzid, !!(endTime && endTime !== ''));
412
+ data.endDate = nextEndLocal.date;
415
413
  if (endTime && endTime !== '') {
416
- data.endTime = newEndDateTimeString.slice(11, 16);
414
+ data.endTime = nextEndLocal.time;
417
415
  }
418
416
  if ((data.recurrence_count && data.recurrence_count !== '') || (data.recurrence_until && data.recurrence_until !== '')) {
419
417
  if (occurenceData.adjustedCount < 2) {
@@ -6,14 +6,14 @@ const tzlibActions = require('timezones-ical-library');
6
6
  * Add to Calendar Button
7
7
  * ++++++++++++++++++++++
8
8
  *
9
- * Version: 2.12.9
9
+ * Version: 2.12.10
10
10
  * Creator: Jens Kuerschner (https://jekuer.com)
11
11
  * Project: https://github.com/add2cal/add-to-calendar-button
12
12
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
13
13
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
14
14
  *
15
15
  */
16
- const atcbVersion = '2.12.9';
16
+ const atcbVersion = '2.12.10';
17
17
  const atcbCssTemplate = {
18
18
  if (typeof window === 'undefined') {
19
19
  return false;
@@ -377,9 +377,10 @@ function atcb_decorate_data_rrule(data) {
377
377
  function atcb_decorate_data_recurring_events(data) {
378
378
  const startDate = data.dates?.[0].startDate || data.startDate;
379
379
  const startTime = data.dates?.[0].startTime || data.startTime;
380
+ const tzid = data.dates?.[0].timeZone || data.timeZone || 'UTC';
381
+ const offset = startTime && startTime !== '' ? tzlibActions.tzlib_get_offset(tzid, startDate, startTime) : '';
380
382
  const startDateTime = (function () {
381
383
  if (startTime && startTime !== '') {
382
- const offset = tzlibActions.tzlib_get_offset(data.dates?.[0].timeZone || data.timeZone, startDate, startTime);
383
384
  return new Date(startDate + ' ' + startTime + ':00 GMT' + offset);
384
385
  }
385
386
  return new Date(startDate + 'T00:00:00Z');
@@ -389,31 +390,28 @@ function atcb_decorate_data_recurring_events(data) {
389
390
  if (!occurenceData || !occurenceData.nextOccurrence) {
390
391
  return data;
391
392
  }
392
- const nextOccurrence =
393
- String(occurenceData.nextOccurrence.getFullYear()) +
394
- '-' +
395
- String(occurenceData.nextOccurrence.getMonth() + 1).padStart(2, '0') +
396
- '-' +
397
- String(occurenceData.nextOccurrence.getDate()).padStart(2, '0') +
398
- (startTime && startTime !== '' ? 'T' + String(occurenceData.nextOccurrence.getHours()).padStart(2, '0') + ':' + String(occurenceData.nextOccurrence.getMinutes()).padStart(2, '0') : '');
399
- data.startDate = nextOccurrence.slice(0, 10);
393
+ function formatInTz(dateObj, timeZone, includeTime) {
394
+ const opts = includeTime ? { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' } : { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit' };
395
+ const parts = new Intl.DateTimeFormat('en-CA', opts).formatToParts(dateObj);
396
+ const get = (t) => parts.find((p) => p.type === t)?.value || '';
397
+ return {
398
+ date: `${get('year')}-${get('month')}-${get('day')}`,
399
+ time: includeTime ? `${get('hour')}:${get('minute')}` : '',
400
+ };
401
+ }
402
+ const nextLocal = formatInTz(occurenceData.nextOccurrence, tzid, !!(startTime && startTime !== ''));
403
+ data.startDate = nextLocal.date;
400
404
  if (startTime && startTime !== '') {
401
- data.startTime = nextOccurrence.slice(11, 16);
405
+ data.startTime = nextLocal.time;
402
406
  }
403
407
  const endDate = data.dates?.[0].endDate || data.endDate || startDate;
404
408
  const endTime = data.dates?.[0].endTime || data.endTime || '';
405
409
  const diff = new Date(endDate + (endTime && endTime !== '' ? 'T' + endTime : '')).getTime() - new Date(startDate + (startTime && startTime !== '' ? 'T' + startTime : '')).getTime();
406
410
  const newEndDateTime = new Date(occurenceData.nextOccurrence.getTime() + diff);
407
- const newEndDateTimeString =
408
- String(newEndDateTime.getFullYear()) +
409
- '-' +
410
- String(newEndDateTime.getMonth() + 1).padStart(2, '0') +
411
- '-' +
412
- String(newEndDateTime.getDate()).padStart(2, '0') +
413
- (endTime && endTime !== '' ? 'T' + String(newEndDateTime.getHours()).padStart(2, '0') + ':' + String(newEndDateTime.getMinutes()).padStart(2, '0') : '');
414
- data.endDate = newEndDateTimeString.slice(0, 10);
411
+ const nextEndLocal = formatInTz(newEndDateTime, tzid, !!(endTime && endTime !== ''));
412
+ data.endDate = nextEndLocal.date;
415
413
  if (endTime && endTime !== '') {
416
- data.endTime = newEndDateTimeString.slice(11, 16);
414
+ data.endTime = nextEndLocal.time;
417
415
  }
418
416
  if ((data.recurrence_count && data.recurrence_count !== '') || (data.recurrence_until && data.recurrence_until !== '')) {
419
417
  if (occurenceData.adjustedCount < 2) {
@@ -6,14 +6,14 @@ const tzlibActions = require('timezones-ical-library');
6
6
  * Add to Calendar Button
7
7
  * ++++++++++++++++++++++
8
8
  *
9
- * Version: 2.12.9
9
+ * Version: 2.12.10
10
10
  * Creator: Jens Kuerschner (https://jekuer.com)
11
11
  * Project: https://github.com/add2cal/add-to-calendar-button
12
12
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
13
13
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
14
14
  *
15
15
  */
16
- const atcbVersion = '2.12.9';
16
+ const atcbVersion = '2.12.10';
17
17
  const atcbCssTemplate = {};
18
18
  const atcbIsBrowser = () => {
19
19
  if (typeof window === 'undefined') {
@@ -378,9 +378,10 @@ function atcb_decorate_data_rrule(data) {
378
378
  function atcb_decorate_data_recurring_events(data) {
379
379
  const startDate = data.dates?.[0].startDate || data.startDate;
380
380
  const startTime = data.dates?.[0].startTime || data.startTime;
381
+ const tzid = data.dates?.[0].timeZone || data.timeZone || 'UTC';
382
+ const offset = startTime && startTime !== '' ? tzlibActions.tzlib_get_offset(tzid, startDate, startTime) : '';
381
383
  const startDateTime = (function () {
382
384
  if (startTime && startTime !== '') {
383
- const offset = tzlibActions.tzlib_get_offset(data.dates?.[0].timeZone || data.timeZone, startDate, startTime);
384
385
  return new Date(startDate + ' ' + startTime + ':00 GMT' + offset);
385
386
  }
386
387
  return new Date(startDate + 'T00:00:00Z');
@@ -390,31 +391,28 @@ function atcb_decorate_data_recurring_events(data) {
390
391
  if (!occurenceData || !occurenceData.nextOccurrence) {
391
392
  return data;
392
393
  }
393
- const nextOccurrence =
394
- String(occurenceData.nextOccurrence.getFullYear()) +
395
- '-' +
396
- String(occurenceData.nextOccurrence.getMonth() + 1).padStart(2, '0') +
397
- '-' +
398
- String(occurenceData.nextOccurrence.getDate()).padStart(2, '0') +
399
- (startTime && startTime !== '' ? 'T' + String(occurenceData.nextOccurrence.getHours()).padStart(2, '0') + ':' + String(occurenceData.nextOccurrence.getMinutes()).padStart(2, '0') : '');
400
- data.startDate = nextOccurrence.slice(0, 10);
394
+ function formatInTz(dateObj, timeZone, includeTime) {
395
+ const opts = includeTime ? { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' } : { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit' };
396
+ const parts = new Intl.DateTimeFormat('en-CA', opts).formatToParts(dateObj);
397
+ const get = (t) => parts.find((p) => p.type === t)?.value || '';
398
+ return {
399
+ date: `${get('year')}-${get('month')}-${get('day')}`,
400
+ time: includeTime ? `${get('hour')}:${get('minute')}` : '',
401
+ };
402
+ }
403
+ const nextLocal = formatInTz(occurenceData.nextOccurrence, tzid, !!(startTime && startTime !== ''));
404
+ data.startDate = nextLocal.date;
401
405
  if (startTime && startTime !== '') {
402
- data.startTime = nextOccurrence.slice(11, 16);
406
+ data.startTime = nextLocal.time;
403
407
  }
404
408
  const endDate = data.dates?.[0].endDate || data.endDate || startDate;
405
409
  const endTime = data.dates?.[0].endTime || data.endTime || '';
406
410
  const diff = new Date(endDate + (endTime && endTime !== '' ? 'T' + endTime : '')).getTime() - new Date(startDate + (startTime && startTime !== '' ? 'T' + startTime : '')).getTime();
407
411
  const newEndDateTime = new Date(occurenceData.nextOccurrence.getTime() + diff);
408
- const newEndDateTimeString =
409
- String(newEndDateTime.getFullYear()) +
410
- '-' +
411
- String(newEndDateTime.getMonth() + 1).padStart(2, '0') +
412
- '-' +
413
- String(newEndDateTime.getDate()).padStart(2, '0') +
414
- (endTime && endTime !== '' ? 'T' + String(newEndDateTime.getHours()).padStart(2, '0') + ':' + String(newEndDateTime.getMinutes()).padStart(2, '0') : '');
415
- data.endDate = newEndDateTimeString.slice(0, 10);
412
+ const nextEndLocal = formatInTz(newEndDateTime, tzid, !!(endTime && endTime !== ''));
413
+ data.endDate = nextEndLocal.date;
416
414
  if (endTime && endTime !== '') {
417
- data.endTime = newEndDateTimeString.slice(11, 16);
415
+ data.endTime = nextEndLocal.time;
418
416
  }
419
417
  if ((data.recurrence_count && data.recurrence_count !== '') || (data.recurrence_until && data.recurrence_until !== '')) {
420
418
  if (occurenceData.adjustedCount < 2) {
@@ -6,14 +6,14 @@ const tzlibActions = require('timezones-ical-library');
6
6
  * Add to Calendar Button
7
7
  * ++++++++++++++++++++++
8
8
  *
9
- * Version: 2.12.9
9
+ * Version: 2.12.10
10
10
  * Creator: Jens Kuerschner (https://jekuer.com)
11
11
  * Project: https://github.com/add2cal/add-to-calendar-button
12
12
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
13
13
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
14
14
  *
15
15
  */
16
- const atcbVersion = '2.12.9';
16
+ const atcbVersion = '2.12.10';
17
17
  const atcbCssTemplate = {};
18
18
  const atcbIsBrowser = () => {
19
19
  if (typeof window === 'undefined') {
@@ -378,9 +378,10 @@ function atcb_decorate_data_rrule(data) {
378
378
  function atcb_decorate_data_recurring_events(data) {
379
379
  const startDate = data.dates?.[0].startDate || data.startDate;
380
380
  const startTime = data.dates?.[0].startTime || data.startTime;
381
+ const tzid = data.dates?.[0].timeZone || data.timeZone || 'UTC';
382
+ const offset = startTime && startTime !== '' ? tzlibActions.tzlib_get_offset(tzid, startDate, startTime) : '';
381
383
  const startDateTime = (function () {
382
384
  if (startTime && startTime !== '') {
383
- const offset = tzlibActions.tzlib_get_offset(data.dates?.[0].timeZone || data.timeZone, startDate, startTime);
384
385
  return new Date(startDate + ' ' + startTime + ':00 GMT' + offset);
385
386
  }
386
387
  return new Date(startDate + 'T00:00:00Z');
@@ -390,31 +391,28 @@ function atcb_decorate_data_recurring_events(data) {
390
391
  if (!occurenceData || !occurenceData.nextOccurrence) {
391
392
  return data;
392
393
  }
393
- const nextOccurrence =
394
- String(occurenceData.nextOccurrence.getFullYear()) +
395
- '-' +
396
- String(occurenceData.nextOccurrence.getMonth() + 1).padStart(2, '0') +
397
- '-' +
398
- String(occurenceData.nextOccurrence.getDate()).padStart(2, '0') +
399
- (startTime && startTime !== '' ? 'T' + String(occurenceData.nextOccurrence.getHours()).padStart(2, '0') + ':' + String(occurenceData.nextOccurrence.getMinutes()).padStart(2, '0') : '');
400
- data.startDate = nextOccurrence.slice(0, 10);
394
+ function formatInTz(dateObj, timeZone, includeTime) {
395
+ const opts = includeTime ? { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' } : { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit' };
396
+ const parts = new Intl.DateTimeFormat('en-CA', opts).formatToParts(dateObj);
397
+ const get = (t) => parts.find((p) => p.type === t)?.value || '';
398
+ return {
399
+ date: `${get('year')}-${get('month')}-${get('day')}`,
400
+ time: includeTime ? `${get('hour')}:${get('minute')}` : '',
401
+ };
402
+ }
403
+ const nextLocal = formatInTz(occurenceData.nextOccurrence, tzid, !!(startTime && startTime !== ''));
404
+ data.startDate = nextLocal.date;
401
405
  if (startTime && startTime !== '') {
402
- data.startTime = nextOccurrence.slice(11, 16);
406
+ data.startTime = nextLocal.time;
403
407
  }
404
408
  const endDate = data.dates?.[0].endDate || data.endDate || startDate;
405
409
  const endTime = data.dates?.[0].endTime || data.endTime || '';
406
410
  const diff = new Date(endDate + (endTime && endTime !== '' ? 'T' + endTime : '')).getTime() - new Date(startDate + (startTime && startTime !== '' ? 'T' + startTime : '')).getTime();
407
411
  const newEndDateTime = new Date(occurenceData.nextOccurrence.getTime() + diff);
408
- const newEndDateTimeString =
409
- String(newEndDateTime.getFullYear()) +
410
- '-' +
411
- String(newEndDateTime.getMonth() + 1).padStart(2, '0') +
412
- '-' +
413
- String(newEndDateTime.getDate()).padStart(2, '0') +
414
- (endTime && endTime !== '' ? 'T' + String(newEndDateTime.getHours()).padStart(2, '0') + ':' + String(newEndDateTime.getMinutes()).padStart(2, '0') : '');
415
- data.endDate = newEndDateTimeString.slice(0, 10);
412
+ const nextEndLocal = formatInTz(newEndDateTime, tzid, !!(endTime && endTime !== ''));
413
+ data.endDate = nextEndLocal.date;
416
414
  if (endTime && endTime !== '') {
417
- data.endTime = newEndDateTimeString.slice(11, 16);
415
+ data.endTime = nextEndLocal.time;
418
416
  }
419
417
  if ((data.recurrence_count && data.recurrence_count !== '') || (data.recurrence_until && data.recurrence_until !== '')) {
420
418
  if (occurenceData.adjustedCount < 2) {
@@ -6,14 +6,14 @@ import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'tim
6
6
  * Add to Calendar Button
7
7
  * ++++++++++++++++++++++
8
8
  *
9
- * Version: 2.12.9
9
+ * Version: 2.12.10
10
10
  * Creator: Jens Kuerschner (https://jekuer.com)
11
11
  * Project: https://github.com/add2cal/add-to-calendar-button
12
12
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
13
13
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
14
14
  *
15
15
  */
16
- const atcbVersion = '2.12.9';
16
+ const atcbVersion = '2.12.10';
17
17
  const atcbCssTemplate = {
18
18
  if (typeof window === 'undefined') {
19
19
  return false;
@@ -377,9 +377,10 @@ function atcb_decorate_data_rrule(data) {
377
377
  function atcb_decorate_data_recurring_events(data) {
378
378
  const startDate = data.dates?.[0].startDate || data.startDate;
379
379
  const startTime = data.dates?.[0].startTime || data.startTime;
380
+ const tzid = data.dates?.[0].timeZone || data.timeZone || 'UTC';
381
+ const offset = startTime && startTime !== '' ? tzlib_get_offset(tzid, startDate, startTime) : '';
380
382
  const startDateTime = (function () {
381
383
  if (startTime && startTime !== '') {
382
- const offset = tzlib_get_offset(data.dates?.[0].timeZone || data.timeZone, startDate, startTime);
383
384
  return new Date(startDate + ' ' + startTime + ':00 GMT' + offset);
384
385
  }
385
386
  return new Date(startDate + 'T00:00:00Z');
@@ -389,31 +390,28 @@ function atcb_decorate_data_recurring_events(data) {
389
390
  if (!occurenceData || !occurenceData.nextOccurrence) {
390
391
  return data;
391
392
  }
392
- const nextOccurrence =
393
- String(occurenceData.nextOccurrence.getFullYear()) +
394
- '-' +
395
- String(occurenceData.nextOccurrence.getMonth() + 1).padStart(2, '0') +
396
- '-' +
397
- String(occurenceData.nextOccurrence.getDate()).padStart(2, '0') +
398
- (startTime && startTime !== '' ? 'T' + String(occurenceData.nextOccurrence.getHours()).padStart(2, '0') + ':' + String(occurenceData.nextOccurrence.getMinutes()).padStart(2, '0') : '');
399
- data.startDate = nextOccurrence.slice(0, 10);
393
+ function formatInTz(dateObj, timeZone, includeTime) {
394
+ const opts = includeTime ? { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' } : { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit' };
395
+ const parts = new Intl.DateTimeFormat('en-CA', opts).formatToParts(dateObj);
396
+ const get = (t) => parts.find((p) => p.type === t)?.value || '';
397
+ return {
398
+ date: `${get('year')}-${get('month')}-${get('day')}`,
399
+ time: includeTime ? `${get('hour')}:${get('minute')}` : '',
400
+ };
401
+ }
402
+ const nextLocal = formatInTz(occurenceData.nextOccurrence, tzid, !!(startTime && startTime !== ''));
403
+ data.startDate = nextLocal.date;
400
404
  if (startTime && startTime !== '') {
401
- data.startTime = nextOccurrence.slice(11, 16);
405
+ data.startTime = nextLocal.time;
402
406
  }
403
407
  const endDate = data.dates?.[0].endDate || data.endDate || startDate;
404
408
  const endTime = data.dates?.[0].endTime || data.endTime || '';
405
409
  const diff = new Date(endDate + (endTime && endTime !== '' ? 'T' + endTime : '')).getTime() - new Date(startDate + (startTime && startTime !== '' ? 'T' + startTime : '')).getTime();
406
410
  const newEndDateTime = new Date(occurenceData.nextOccurrence.getTime() + diff);
407
- const newEndDateTimeString =
408
- String(newEndDateTime.getFullYear()) +
409
- '-' +
410
- String(newEndDateTime.getMonth() + 1).padStart(2, '0') +
411
- '-' +
412
- String(newEndDateTime.getDate()).padStart(2, '0') +
413
- (endTime && endTime !== '' ? 'T' + String(newEndDateTime.getHours()).padStart(2, '0') + ':' + String(newEndDateTime.getMinutes()).padStart(2, '0') : '');
414
- data.endDate = newEndDateTimeString.slice(0, 10);
411
+ const nextEndLocal = formatInTz(newEndDateTime, tzid, !!(endTime && endTime !== ''));
412
+ data.endDate = nextEndLocal.date;
415
413
  if (endTime && endTime !== '') {
416
- data.endTime = newEndDateTimeString.slice(11, 16);
414
+ data.endTime = nextEndLocal.time;
417
415
  }
418
416
  if ((data.recurrence_count && data.recurrence_count !== '') || (data.recurrence_until && data.recurrence_until !== '')) {
419
417
  if (occurenceData.adjustedCount < 2) {
@@ -6,14 +6,14 @@ import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'tim
6
6
  * Add to Calendar Button
7
7
  * ++++++++++++++++++++++
8
8
  *
9
- * Version: 2.12.9
9
+ * Version: 2.12.10
10
10
  * Creator: Jens Kuerschner (https://jekuer.com)
11
11
  * Project: https://github.com/add2cal/add-to-calendar-button
12
12
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
13
13
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
14
14
  *
15
15
  */
16
- const atcbVersion = '2.12.9';
16
+ const atcbVersion = '2.12.10';
17
17
  const atcbCssTemplate = {
18
18
  if (typeof window === 'undefined') {
19
19
  return false;
@@ -377,9 +377,10 @@ function atcb_decorate_data_rrule(data) {
377
377
  function atcb_decorate_data_recurring_events(data) {
378
378
  const startDate = data.dates?.[0].startDate || data.startDate;
379
379
  const startTime = data.dates?.[0].startTime || data.startTime;
380
+ const tzid = data.dates?.[0].timeZone || data.timeZone || 'UTC';
381
+ const offset = startTime && startTime !== '' ? tzlib_get_offset(tzid, startDate, startTime) : '';
380
382
  const startDateTime = (function () {
381
383
  if (startTime && startTime !== '') {
382
- const offset = tzlib_get_offset(data.dates?.[0].timeZone || data.timeZone, startDate, startTime);
383
384
  return new Date(startDate + ' ' + startTime + ':00 GMT' + offset);
384
385
  }
385
386
  return new Date(startDate + 'T00:00:00Z');
@@ -389,31 +390,28 @@ function atcb_decorate_data_recurring_events(data) {
389
390
  if (!occurenceData || !occurenceData.nextOccurrence) {
390
391
  return data;
391
392
  }
392
- const nextOccurrence =
393
- String(occurenceData.nextOccurrence.getFullYear()) +
394
- '-' +
395
- String(occurenceData.nextOccurrence.getMonth() + 1).padStart(2, '0') +
396
- '-' +
397
- String(occurenceData.nextOccurrence.getDate()).padStart(2, '0') +
398
- (startTime && startTime !== '' ? 'T' + String(occurenceData.nextOccurrence.getHours()).padStart(2, '0') + ':' + String(occurenceData.nextOccurrence.getMinutes()).padStart(2, '0') : '');
399
- data.startDate = nextOccurrence.slice(0, 10);
393
+ function formatInTz(dateObj, timeZone, includeTime) {
394
+ const opts = includeTime ? { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' } : { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit' };
395
+ const parts = new Intl.DateTimeFormat('en-CA', opts).formatToParts(dateObj);
396
+ const get = (t) => parts.find((p) => p.type === t)?.value || '';
397
+ return {
398
+ date: `${get('year')}-${get('month')}-${get('day')}`,
399
+ time: includeTime ? `${get('hour')}:${get('minute')}` : '',
400
+ };
401
+ }
402
+ const nextLocal = formatInTz(occurenceData.nextOccurrence, tzid, !!(startTime && startTime !== ''));
403
+ data.startDate = nextLocal.date;
400
404
  if (startTime && startTime !== '') {
401
- data.startTime = nextOccurrence.slice(11, 16);
405
+ data.startTime = nextLocal.time;
402
406
  }
403
407
  const endDate = data.dates?.[0].endDate || data.endDate || startDate;
404
408
  const endTime = data.dates?.[0].endTime || data.endTime || '';
405
409
  const diff = new Date(endDate + (endTime && endTime !== '' ? 'T' + endTime : '')).getTime() - new Date(startDate + (startTime && startTime !== '' ? 'T' + startTime : '')).getTime();
406
410
  const newEndDateTime = new Date(occurenceData.nextOccurrence.getTime() + diff);
407
- const newEndDateTimeString =
408
- String(newEndDateTime.getFullYear()) +
409
- '-' +
410
- String(newEndDateTime.getMonth() + 1).padStart(2, '0') +
411
- '-' +
412
- String(newEndDateTime.getDate()).padStart(2, '0') +
413
- (endTime && endTime !== '' ? 'T' + String(newEndDateTime.getHours()).padStart(2, '0') + ':' + String(newEndDateTime.getMinutes()).padStart(2, '0') : '');
414
- data.endDate = newEndDateTimeString.slice(0, 10);
411
+ const nextEndLocal = formatInTz(newEndDateTime, tzid, !!(endTime && endTime !== ''));
412
+ data.endDate = nextEndLocal.date;
415
413
  if (endTime && endTime !== '') {
416
- data.endTime = newEndDateTimeString.slice(11, 16);
414
+ data.endTime = nextEndLocal.time;
417
415
  }
418
416
  if ((data.recurrence_count && data.recurrence_count !== '') || (data.recurrence_until && data.recurrence_until !== '')) {
419
417
  if (occurenceData.adjustedCount < 2) {
@@ -6,14 +6,14 @@ import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'tim
6
6
  * Add to Calendar Button
7
7
  * ++++++++++++++++++++++
8
8
  *
9
- * Version: 2.12.9
9
+ * Version: 2.12.10
10
10
  * Creator: Jens Kuerschner (https://jekuer.com)
11
11
  * Project: https://github.com/add2cal/add-to-calendar-button
12
12
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
13
13
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
14
14
  *
15
15
  */
16
- const atcbVersion = '2.12.9';
16
+ const atcbVersion = '2.12.10';
17
17
  const atcbCssTemplate = {};
18
18
  const atcbIsBrowser = () => {
19
19
  if (typeof window === 'undefined') {
@@ -378,9 +378,10 @@ function atcb_decorate_data_rrule(data) {
378
378
  function atcb_decorate_data_recurring_events(data) {
379
379
  const startDate = data.dates?.[0].startDate || data.startDate;
380
380
  const startTime = data.dates?.[0].startTime || data.startTime;
381
+ const tzid = data.dates?.[0].timeZone || data.timeZone || 'UTC';
382
+ const offset = startTime && startTime !== '' ? tzlib_get_offset(tzid, startDate, startTime) : '';
381
383
  const startDateTime = (function () {
382
384
  if (startTime && startTime !== '') {
383
- const offset = tzlib_get_offset(data.dates?.[0].timeZone || data.timeZone, startDate, startTime);
384
385
  return new Date(startDate + ' ' + startTime + ':00 GMT' + offset);
385
386
  }
386
387
  return new Date(startDate + 'T00:00:00Z');
@@ -390,31 +391,28 @@ function atcb_decorate_data_recurring_events(data) {
390
391
  if (!occurenceData || !occurenceData.nextOccurrence) {
391
392
  return data;
392
393
  }
393
- const nextOccurrence =
394
- String(occurenceData.nextOccurrence.getFullYear()) +
395
- '-' +
396
- String(occurenceData.nextOccurrence.getMonth() + 1).padStart(2, '0') +
397
- '-' +
398
- String(occurenceData.nextOccurrence.getDate()).padStart(2, '0') +
399
- (startTime && startTime !== '' ? 'T' + String(occurenceData.nextOccurrence.getHours()).padStart(2, '0') + ':' + String(occurenceData.nextOccurrence.getMinutes()).padStart(2, '0') : '');
400
- data.startDate = nextOccurrence.slice(0, 10);
394
+ function formatInTz(dateObj, timeZone, includeTime) {
395
+ const opts = includeTime ? { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' } : { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit' };
396
+ const parts = new Intl.DateTimeFormat('en-CA', opts).formatToParts(dateObj);
397
+ const get = (t) => parts.find((p) => p.type === t)?.value || '';
398
+ return {
399
+ date: `${get('year')}-${get('month')}-${get('day')}`,
400
+ time: includeTime ? `${get('hour')}:${get('minute')}` : '',
401
+ };
402
+ }
403
+ const nextLocal = formatInTz(occurenceData.nextOccurrence, tzid, !!(startTime && startTime !== ''));
404
+ data.startDate = nextLocal.date;
401
405
  if (startTime && startTime !== '') {
402
- data.startTime = nextOccurrence.slice(11, 16);
406
+ data.startTime = nextLocal.time;
403
407
  }
404
408
  const endDate = data.dates?.[0].endDate || data.endDate || startDate;
405
409
  const endTime = data.dates?.[0].endTime || data.endTime || '';
406
410
  const diff = new Date(endDate + (endTime && endTime !== '' ? 'T' + endTime : '')).getTime() - new Date(startDate + (startTime && startTime !== '' ? 'T' + startTime : '')).getTime();
407
411
  const newEndDateTime = new Date(occurenceData.nextOccurrence.getTime() + diff);
408
- const newEndDateTimeString =
409
- String(newEndDateTime.getFullYear()) +
410
- '-' +
411
- String(newEndDateTime.getMonth() + 1).padStart(2, '0') +
412
- '-' +
413
- String(newEndDateTime.getDate()).padStart(2, '0') +
414
- (endTime && endTime !== '' ? 'T' + String(newEndDateTime.getHours()).padStart(2, '0') + ':' + String(newEndDateTime.getMinutes()).padStart(2, '0') : '');
415
- data.endDate = newEndDateTimeString.slice(0, 10);
412
+ const nextEndLocal = formatInTz(newEndDateTime, tzid, !!(endTime && endTime !== ''));
413
+ data.endDate = nextEndLocal.date;
416
414
  if (endTime && endTime !== '') {
417
- data.endTime = newEndDateTimeString.slice(11, 16);
415
+ data.endTime = nextEndLocal.time;
418
416
  }
419
417
  if ((data.recurrence_count && data.recurrence_count !== '') || (data.recurrence_until && data.recurrence_until !== '')) {
420
418
  if (occurenceData.adjustedCount < 2) {
@@ -6,14 +6,14 @@ import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'tim
6
6
  * Add to Calendar Button
7
7
  * ++++++++++++++++++++++
8
8
  *
9
- * Version: 2.12.9
9
+ * Version: 2.12.10
10
10
  * Creator: Jens Kuerschner (https://jekuer.com)
11
11
  * Project: https://github.com/add2cal/add-to-calendar-button
12
12
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
13
13
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
14
14
  *
15
15
  */
16
- const atcbVersion = '2.12.9';
16
+ const atcbVersion = '2.12.10';
17
17
  const atcbCssTemplate = {};
18
18
  const atcbIsBrowser = () => {
19
19
  if (typeof window === 'undefined') {
@@ -378,9 +378,10 @@ function atcb_decorate_data_rrule(data) {
378
378
  function atcb_decorate_data_recurring_events(data) {
379
379
  const startDate = data.dates?.[0].startDate || data.startDate;
380
380
  const startTime = data.dates?.[0].startTime || data.startTime;
381
+ const tzid = data.dates?.[0].timeZone || data.timeZone || 'UTC';
382
+ const offset = startTime && startTime !== '' ? tzlib_get_offset(tzid, startDate, startTime) : '';
381
383
  const startDateTime = (function () {
382
384
  if (startTime && startTime !== '') {
383
- const offset = tzlib_get_offset(data.dates?.[0].timeZone || data.timeZone, startDate, startTime);
384
385
  return new Date(startDate + ' ' + startTime + ':00 GMT' + offset);
385
386
  }
386
387
  return new Date(startDate + 'T00:00:00Z');
@@ -390,31 +391,28 @@ function atcb_decorate_data_recurring_events(data) {
390
391
  if (!occurenceData || !occurenceData.nextOccurrence) {
391
392
  return data;
392
393
  }
393
- const nextOccurrence =
394
- String(occurenceData.nextOccurrence.getFullYear()) +
395
- '-' +
396
- String(occurenceData.nextOccurrence.getMonth() + 1).padStart(2, '0') +
397
- '-' +
398
- String(occurenceData.nextOccurrence.getDate()).padStart(2, '0') +
399
- (startTime && startTime !== '' ? 'T' + String(occurenceData.nextOccurrence.getHours()).padStart(2, '0') + ':' + String(occurenceData.nextOccurrence.getMinutes()).padStart(2, '0') : '');
400
- data.startDate = nextOccurrence.slice(0, 10);
394
+ function formatInTz(dateObj, timeZone, includeTime) {
395
+ const opts = includeTime ? { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' } : { timeZone, hour12: false, year: 'numeric', month: '2-digit', day: '2-digit' };
396
+ const parts = new Intl.DateTimeFormat('en-CA', opts).formatToParts(dateObj);
397
+ const get = (t) => parts.find((p) => p.type === t)?.value || '';
398
+ return {
399
+ date: `${get('year')}-${get('month')}-${get('day')}`,
400
+ time: includeTime ? `${get('hour')}:${get('minute')}` : '',
401
+ };
402
+ }
403
+ const nextLocal = formatInTz(occurenceData.nextOccurrence, tzid, !!(startTime && startTime !== ''));
404
+ data.startDate = nextLocal.date;
401
405
  if (startTime && startTime !== '') {
402
- data.startTime = nextOccurrence.slice(11, 16);
406
+ data.startTime = nextLocal.time;
403
407
  }
404
408
  const endDate = data.dates?.[0].endDate || data.endDate || startDate;
405
409
  const endTime = data.dates?.[0].endTime || data.endTime || '';
406
410
  const diff = new Date(endDate + (endTime && endTime !== '' ? 'T' + endTime : '')).getTime() - new Date(startDate + (startTime && startTime !== '' ? 'T' + startTime : '')).getTime();
407
411
  const newEndDateTime = new Date(occurenceData.nextOccurrence.getTime() + diff);
408
- const newEndDateTimeString =
409
- String(newEndDateTime.getFullYear()) +
410
- '-' +
411
- String(newEndDateTime.getMonth() + 1).padStart(2, '0') +
412
- '-' +
413
- String(newEndDateTime.getDate()).padStart(2, '0') +
414
- (endTime && endTime !== '' ? 'T' + String(newEndDateTime.getHours()).padStart(2, '0') + ':' + String(newEndDateTime.getMinutes()).padStart(2, '0') : '');
415
- data.endDate = newEndDateTimeString.slice(0, 10);
412
+ const nextEndLocal = formatInTz(newEndDateTime, tzid, !!(endTime && endTime !== ''));
413
+ data.endDate = nextEndLocal.date;
416
414
  if (endTime && endTime !== '') {
417
- data.endTime = newEndDateTimeString.slice(11, 16);
415
+ data.endTime = nextEndLocal.time;
418
416
  }
419
417
  if ((data.recurrence_count && data.recurrence_count !== '') || (data.recurrence_until && data.recurrence_until !== '')) {
420
418
  if (occurenceData.adjustedCount < 2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "add-to-calendar-button",
3
- "version": "2.12.9",
3
+ "version": "2.12.10",
4
4
  "engines": {
5
5
  "node": ">=18.17.0",
6
6
  "npm": ">=9.6.7"