bunkat / later

A javascript library for defining recurring schedules and calculating future (or past) occurrences for them. Includes support for using English phrases and Cron schedules. Works in Node and in the browser.
http://bunkat.github.io/later/
MIT License
2.42k stars 245 forks source link

localTime not picking up correct date #195

Open boredstiff opened 7 years ago

boredstiff commented 7 years ago
later.date.localTime()
let my_schedule = later.parse.text('at 16:48 every day')
let times = later.schedule(my_schedule).next(10)
console.log(times)

seems to be returning the following for me:

[ 2017-02-01T21:48:00.000Z,
  2017-03-01T21:48:00.000Z,
  2017-04-01T20:48:00.000Z,
  2017-05-01T20:48:00.000Z,
  2017-06-01T20:48:00.000Z,
  2017-07-01T20:48:00.000Z,
  2017-08-01T20:48:00.000Z,
  2017-09-01T20:48:00.000Z,
  2017-10-01T20:48:00.000Z,
  2017-11-01T20:48:00.000Z ]

So it appears that - on initialization - it's picking up the correct year, but starting on January 1st - even though today is January 15th.

I've double-checked but can't find anything that I've skipped - any clues?

Thanks!

bunkat commented 7 years ago

I haven't seen this before, unfortunately. You can set a break point and see what start date it is pulling in or try setting one explicitly in the .next() function call.

boredstiff commented 7 years ago

I'll give it a shot sometime in the next few days if I go back to the project that was using this and will follow up. Thanks!

sergibondarenko commented 6 years ago

It doesn't work for me too. Code

const later = require('later');

later.date.localTime();
let schedule = later.parse.text('every 1 min');
let times = later.schedule(schedule).next(10);
console.log(times);

Result

[ 2018-03-26T10:30:30.909Z,
  2018-03-26T10:31:00.000Z,
  2018-03-26T10:32:00.000Z,
  2018-03-26T10:33:00.000Z,
  2018-03-26T10:34:00.000Z,
  2018-03-26T10:35:00.000Z,
  2018-03-26T10:36:00.000Z,
  2018-03-26T10:37:00.000Z,
  2018-03-26T10:38:00.000Z,
  2018-03-26T10:39:00.000Z ]

Expected result (timezone Europe/Rome)

[ 2018-03-26T12:30:30.909Z,
  2018-03-26T12:31:00.000Z,
  2018-03-26T12:32:00.000Z,
  2018-03-26T12:33:00.000Z,
  2018-03-26T12:34:00.000Z,
  2018-03-26T12:35:00.000Z,
  2018-03-26T12:36:00.000Z,
  2018-03-26T12:37:00.000Z,
  2018-03-26T12:38:00.000Z,
  2018-03-26T12:39:00.000Z ]