Search code examples
javascriptlaterjs

Calculate dates with Later.js


I am trying to calculate complex dates with Later.js.

I want to to things like: "on the third Tuesday of every month"

but I get an error pointing to 'third'. According to the docs, only 'first' and 'last' are recoginzed...ok, so if I change it to: "on the first Tuesday of every month"

Then the error is at 'Tuesday'.

Anyone know how I can use Later.js to figure such dates using the text parser?


Solution

  • You can do it by using "day instance" phrase which works on later.parse.text or "dayOfWeekCount()" method which works on later.parse.recur()

    for example on 3rd tuesday on every month you can write

    var sched = later.parse.text("on the 3rd day instance on Tues at 16:00")
    

    OR

    var sched = later.parse.recur().on(3).dayOfWeekCount().on(3).dayOfWeek().on("8:00").time()