breejs / later

*Maintained fork of 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.
https://breejs.github.io/later/
MIT License
134 stars 13 forks source link

incompatible with "clj-fuzzy" #8

Open nitramreffehcs opened 3 years ago

nitramreffehcs commented 3 years ago

hi, apparently this module doesn't work after "clj-fuzzy" is loaded, i have no idea why, as that module is minified

this is my test code:

const later = require('@breejs/later')

const parsedSchedule = later.parse.text('at 0:00') const scheduleObject = later.schedule(parsedSchedule) let next

next = scheduleObject.next(2)

if (next[0].getTime() === next[1].getTime()) { console.log('NOT OK') } else { console.log('OK') }

require('clj-fuzzy')

next = scheduleObject.next(2)

if (next[0].getTime() === next[1].getTime()) { console.log('NOT OK') } else { console.log('OK') }

in the second test both dates returned by "next" are identical, the current time

FOUND IT !!

that module does this (yes that is totaly wrong) Date.prototype.s = function (a, b) { return b instanceof Date && this.valueOf() === b.valueOf() and later does

val: function val(d) { return d.s || (d.s = later.date.getSec.call(d)); },

(line 363) but, d is a standard javascript date at that time, i understand that this is some kind of optimization ? (are seconds cached this way ?

of course attaching methods to global classes is the problem here, but attaching properties isn't very safe either sadly that other module isn't being maintained