totaljs / framework

Node.js framework
http://www.totaljs.com
Other
4.36k stars 450 forks source link

F.schedule repeat format to do a job monthly #647

Closed ckpiggy closed 6 years ago

ckpiggy commented 6 years ago

I want to trigger a job on 5th day every month. How can I use F.schedule to achieve this ? My idea is

F.schedule('0:00', '1 day', function () {
  const date = new Date().getDate()
  if (date === 5) {
    //do the work
  }
})

I wonder if there is any better way to do this ?

petersirka commented 6 years ago

Hi @ckpiggy, this is good way how to handle it or:

ON('service', function() {
    if (F.datetime.format('dd:HH:mm') === '05:00:00') {
         console.log('5th day');
    }
});