Skip to content

Commit 2c9fb8f

Browse files
committed
2000: Reverted change to rrule dtstart
1 parent 98a7184 commit 2c9fb8f

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
- Reverted change in https://github.com/os2display/display-admin-client/commit/65762066c708f541305a48fbd6b28264dca593b5.
8+
- Added comments about how rrules are handled.
9+
710
- [#242](https://github.com/os2display/display-admin-client/pull/243)
811
- Add entry in example config for midttrafik api key
912
- Clean up multi select component a bit, replace reduce with Map logic

src/components/util/schedule/schedule-util.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ dayjs.extend(localizedFormat);
1111
/**
1212
* Get rrule string from schedule.
1313
*
14+
*
15+
*
1416
* @param {object} schedule - The schedule.
1517
* @returns {string} - RRule string.
1618
*/
@@ -56,7 +58,18 @@ const createNewSchedule = () => {
5658
id: ulid(nowTimestamp),
5759
duration: 60 * 60 * 24, // Default one day.
5860
freq: RRule.WEEKLY,
59-
dtstart: new Date(),
61+
// For evaluation with the RRule library we pretend that "now" is in UTC instead of the local timezone.
62+
// That is 9:00 in Europe/Copenhagen time will be evaluated as if it was 9:00 in UTC.
63+
// @see https://github.com/jkbrzt/rrule#important-use-utc-dates
64+
dtstart: new Date(
65+
Date.UTC(
66+
now.getFullYear(),
67+
now.getMonth(),
68+
now.getDate(),
69+
now.getHours(),
70+
now.getMinutes()
71+
)
72+
),
6073
until: null,
6174
wkst: RRule.MO,
6275
byhour: null,

src/components/util/schedule/schedule.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,17 @@ function Schedule({ schedules, onChange }) {
120120
*/
121121
const setDateValue = (scheduleId, target) => {
122122
const date = new Date(target.value);
123-
changeSchedule(scheduleId, target.id, date);
123+
124+
// For evaluation with the RRule library we pretend that the date is in UTC instead of the local timezone.
125+
// That is 9:00 in Europe/Copenhagen time will be evaluated as if it was 9:00 in UTC.
126+
// @see https://github.com/jkbrzt/rrule#important-use-utc-dates
127+
changeSchedule(scheduleId, target.id, new Date(Date.UTC(
128+
date.getFullYear(),
129+
date.getMonth(),
130+
date.getDate(),
131+
date.getHours(),
132+
date.getMinutes()
133+
)));
124134
};
125135

126136
/**
@@ -130,7 +140,7 @@ function Schedule({ schedules, onChange }) {
130140
* @returns {string} - The date formatted for datetime-local.
131141
*/
132142
const getDateValue = (date) => {
133-
return date ? dayjs(date).format("YYYY-MM-DDTHH:mm") : "";
143+
return date ? dayjs(date).utc().format("YYYY-MM-DDTHH:mm") : "";
134144
};
135145

136146
/**
@@ -342,6 +352,7 @@ function Schedule({ schedules, onChange }) {
342352
<div id="schedule_details" className="row">
343353
<strong>{t("schedule.rrulestring")}:</strong>
344354
<span>{schedule.rrule}</span>
355+
<small>{t("schedule.rrulestring-z-ignored")}</small>
345356
<div className="mt-2">
346357
<strong>{t("schedule.next-occurrences")}:</strong>
347358
{getNextOccurrences(schedule.rruleObject).map(

src/translations/da/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,7 @@
776776
"hourly": "Time",
777777
"minutely": "Minut",
778778
"rrulestring": "RRule",
779+
"rrulestring-z-ignored": "Bemærk at tidszonen (Z) bliver ignoreret i evalueringen af reglen. Tidsangivelserne vil altid blive behandlet i lokal tid.",
779780
"dtstart": "Startdato",
780781
"until": "Slutdato",
781782
"next-occurrences": "Næste 5 forekomster",

0 commit comments

Comments
 (0)