rrule
rrule copied to clipboard
Wrong result of the between function when machine local timezone greater than GMT+12
Hello!
There seems to be an issue with rrule 'between' function results when the local timezone is greater than GMT+12 (e.g. Apia Standard Time GMT+13 timezone)
Here is the simple script to reproduce this issue:
import rrule from 'rrule';
const { RRule } = rrule;
const startDate = new Date('2021-03-23T10:00:00Z');
const minDate = new Date('2021-03-20T00:00:00Z');
const maxDate = new Date('2021-03-26T00:00:00Z');
const rule = new RRule({
freq: RRule.DAILY,
dtstart: startDate,
});
const result = rule.between(minDate, maxDate, true);
console.log('result: ', result);
With a local machine's time zone GMT+12 (e.g. Fiji Standard Time) the console output is correct:
result: [
2021-03-23T10:00:00.000Z,
2021-03-24T10:00:00.000Z,
2021-03-25T10:00:00.000Z
]
But, with a local machine's time zone GMT+13 (e.g. Apia Standard Time), the console output is incorrect:
result: [ 2021-03-24T10:00:00.000Z, 2021-03-25T10:00:00.000Z ]
2021-03-23T10:00:00.000Z is missing here.
Reporting an issue
Thank you for taking an interest in rrule! Please include the following in
your report:
- [x] Verify that you've looked through existing issues for duplicates before creating a new one
- [x] Code sample reproducing the issue. Be sure to include all input values you are using such as the exact RRule string and dates.
- [x] Expected output
- [x] Actual output
- [x] The version of
rruleyou are using - [x] Your operating system
- [x] Your local timezone (run
$ datefrom the command line of the machine showing the bug)
Operating system: macOS 12.4 (Monterey) Node: v16.15.1 Timezone: Apia Standart Time RRule version: 2.7.1 (latest)
I've also ran into the same issue. I was using RRule.fromString(rruleInStringFormat) to generate the RRules, but when it comes to obtaining any date with after or between, it starts with a date+1 day (e.g. gives Tuesday where it should give Monday). Funny thing is, that it returns correct hours/minutes, but not the date.
Can it be somehow related to https://github.com/jakubroztocil/rrule/issues/537 (redundant timezone maths)?