I am using rSchedule to produce working hour intervals.But timezone is ignored. How can I achieve it?
The input is working hour intervals in a day, with timezone as below.
const input = {
workingHours:[{start:9, end:12}, {start:13, end:18}],
timeZone:'Europe/Berlin'
};
With the below code, I am expecting to produce intervals with respect to day light shiftings in a year. However, the produced output ignores the timeZone I provided.
import { Schedule } from "@rschedule/core/generators";
import '@rschedule/moment-tz-date-adapter/setup';
import moment from 'moment-timezone';
const schedule = new Schedule({
rrules: [
{
frequency: "MONTHLY",//frequency: "WEEKLY",
//byDayOfWeek: ["MO", 'TU', 'WE', 'TH', 'FR'],
duration:1000 * 60 * 60 * 3,//input.workingHours[0].end-input.workingHours[0].start,
byHourOfDay:[12],//input.workingHours[0].end
timezone:'Europe/Berlin',//input.timeZone,
start: moment(Date.UTC(2019, 0, 1)),
end: moment(Date.UTC(2020, 0, 0))
}
]
});
schedule.occurrences().toArray().forEach(adapter => {
console.log(
{
start: adapter.date.toISOString(),
end: adapter.end.toISOString(),
}
)
})
Output ignoring timezone:
{ start: '2019-01-01T09:00:00.000Z', end: '2019-01-01T12:00:00.000Z' }
{ start: '2019-02-01T09:00:00.000Z', end: '2019-02-01T12:00:00.000Z' }
{ start: '2019-03-01T09:00:00.000Z', end: '2019-03-01T12:00:00.000Z' }
{ start: '2019-04-01T09:00:00.000Z', end: '2019-04-01T12:00:00.000Z' }
{ start: '2019-05-01T09:00:00.000Z', end: '2019-05-01T12:00:00.000Z' }
{ start: '2019-06-01T09:00:00.000Z', end: '2019-06-01T12:00:00.000Z' }
{ start: '2019-07-01T09:00:00.000Z', end: '2019-07-01T12:00:00.000Z' }
{ start: '2019-08-01T09:00:00.000Z', end: '2019-08-01T12:00:00.000Z' }
{ start: '2019-09-01T09:00:00.000Z', end: '2019-09-01T12:00:00.000Z' }
{ start: '2019-10-01T09:00:00.000Z', end: '2019-10-01T12:00:00.000Z' }
{ start: '2019-11-01T09:00:00.000Z', end: '2019-11-01T12:00:00.000Z' }
{ start: '2019-12-01T09:00:00.000Z', end: '2019-12-01T12:00:00.000Z' }
Expected output:
{ start: '2019-01-01T11:00:00.000Z', end: '2019-01-01T14:00:00.000Z' },
{ start: '2019-02-01T11:00:00.000Z', end: '2019-02-01T14:00:00.000Z' },
{ start: '2019-03-01T11:00:00.000Z', end: '2019-03-01T14:00:00.000Z' },
{ start: '2019-04-01T10:00:00.000Z', end: '2019-04-01T13:00:00.000Z' },
{ start: '2019-05-01T10:00:00.000Z', end: '2019-05-01T13:00:00.000Z' },
{ start: '2019-06-01T10:00:00.000Z', end: '2019-06-01T13:00:00.000Z' },
{ start: '2019-07-01T10:00:00.000Z', end: '2019-07-01T13:00:00.000Z' },
{ start: '2019-08-01T10:00:00.000Z', end: '2019-08-01T13:00:00.000Z' },
{ start: '2019-09-01T10:00:00.000Z', end: '2019-09-01T13:00:00.000Z' },
{ start: '2019-10-01T10:00:00.000Z', end: '2019-10-01T13:00:00.000Z' },
{ start: '2019-11-01T11:00:00.000Z', end: '2019-11-01T14:00:00.000Z' },
{ start: '2019-12-01T11:00:00.000Z', end: '2019-12-01T14:00:00.000Z' }
moment
wuthout any tz set to it. – Studio