Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong occurance on day of daylight savings change #157

Closed
anupvarghese opened this issue Oct 2, 2016 · 4 comments
Closed

Wrong occurance on day of daylight savings change #157

anupvarghese opened this issue Oct 2, 2016 · 4 comments
Labels

Comments

@anupvarghese
Copy link

Yes, it looks a bit confusing from the issue header. Here is the description

Today (2nd - Oct -2016 -Australia/Sydney) time has changed with a daylight savings (1 hr further).

I have the below snippet to explain the issue,
By the iCal string it is scheduled to run Weekly by Sunday at 16 HRS

const rrule = require('rrule');
const moment = require('moment-timezone');
let opts = rrule.RRule.parseString('FREQ=WEEKLY;BYDAY=SU;BYHOUR=16;BYMINUTE=00')
opts.dtstart = moment.tz('Australia/Sydney').subtract('30', 'days').toDate();
const rule = new rrule.RRule(opts)
const today = moment.tz('Australia/Sydney').startOf('day')();
rule.after(today, true);

Here is what I get when I run the below,

> rule.between(new Date(2016, 8, 1), new Date(2016, 10, 1)).map(p => console.log(p));

Sun Sep 04 2016 16:00:56 GMT+1000 (AEST)
Sun Sep 11 2016 16:00:56 GMT+1000 (AEST)
Sun Sep 18 2016 16:00:56 GMT+1000 (AEST)
Sun Sep 25 2016 16:00:56 GMT+1000 (AEST)
Sat Oct 01 2016 16:00:56 GMT+1000 (AEST)
Sun Oct 09 2016 16:00:56 GMT+1100 (AEDT)
Sun Oct 16 2016 16:00:56 GMT+1100 (AEDT)
Sun Oct 23 2016 16:00:56 GMT+1100 (AEDT)
Sun Oct 30 2016 16:00:56 GMT+1100 (AEDT)

On the day when the day light savings changed, it is behaving differently (Look at the bold text)

@deep-c
Copy link

deep-c commented Oct 6, 2016

Same issue here. using rrulestr to parse the following RRULE:FREQ=DAILY;UNTIL=20161005T000000Z\nEXRULE:FREQ=DAILY;UNTIL=20160925T000000Z, I get the following list of dates:

Mon Sep 26 2016 00:00:00 GMT+1000 (AEST)
Tue Sep 27 2016 00:00:00 GMT+1000 (AEST)
Wed Sep 28 2016 00:00:00 GMT+1000 (AEST)
Thu Sep 29 2016 00:00:00 GMT+1000 (AEST)
Fri Sep 30 2016 00:00:00 GMT+1000 (AEST)
Sat Oct 01 2016 00:00:00 GMT+1000 (AEST)
Mon Oct 03 2016 00:00:00 GMT+1100 (AEDT)
Tue Oct 04 2016 00:00:00 GMT+1100 (AEDT)
Wed Oct 05 2016 00:00:00 GMT+1100 (AEDT)

OCT 2 is missing.

@raphaelm
Copy link

For our use cases, it can apparently be fixed by just removing timezone awareness from fromOrdinal, which appears to make sense since toOrdinal apparently removes timezone information already.

    fromOrdinal: function (ordinal) {
      var millisecsFromBase = ordinal * dateutil.ONE_DAY
      return new Date(dateutil.ORDINAL_BASE.getTime() +
        millisecsFromBase);
    },

I'm not sure if this has implications that I'm not aware of, though, since I did not dive deep into the code. @espen @jakubroztocil do you see any problems with this or should I create a PR?

@SystemParadox
Copy link

I have a similar issue (UK timezone):

var { RRule } = require('rrule');
var rule = new RRule({
    freq: RRule.WEEKLY,
    dtstart: new Date(2018, 9, 22, 12),
    until: new Date(2018, 10, 19, 12),
});
console.log(rule.all());

In rrule 2.2.9 this gives:

[ 2018-10-22T11:00:00.000Z,
  2018-10-28T12:00:00.000Z,
  2018-11-05T12:00:00.000Z,
  2018-11-12T12:00:00.000Z,
  2018-11-19T12:00:00.000Z ]

Daylight savings time ends on the 28th October. All the occurrences from this date onwards are shifted one day earlier.

The above change to fromOrdinal appears to fix it.

@davidgoli
Copy link
Collaborator

@anupvarghese I believe this has been fixed in 2.3.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants