shawnchin / jquery-cron

A jQuery plugin to provide a simplified interface for users to specify cron entries
http://shawnchin.github.io/jquery-cron
MIT License
177 stars 118 forks source link

Set week to start on Sunday #1

Closed ShirtlessKirk closed 13 years ago

ShirtlessKirk commented 13 years ago

Cron weeks start on a Sunday. Thus Sunday should be 0 (see http://en.wikipedia.org/wiki/Cron#Predefined_scheduling_definitions ). FWIW this tallies with JavaScript's .getDay() function.

shawnchin commented 13 years ago

Many thanks phil. I'm currently on the move and will be back in 2 weeks. I'll have a look and merge it when I get back.

Regards, Shawn

On 5 Oct 2011, at 10:24, Phil Greenreply@reply.github.com wrote:

Cron weeks start on a Sunday. Thus Sunday should be 0 (see http://en.wikipedia.org/wiki/Cron#Predefined_scheduling_definitions ). FWIW this tallies with JavaScript's .getDay() function.

You can merge this Pull Request by running:

git pull https://github.com/ShirtlessKirk/jquery-cron patch-1

Or you can view, comment on it, or merge it online at:

https://github.com/shawnchin/jquery-cron/pull/1

-- Commit Summary --

  • Set week to start on Sunday

-- File Changes --

M cron/jquery-cron.js (4)

-- Patch Links --

https://github.com/shawnchin/jquery-cron/pull/1.patch https://github.com/shawnchin/jquery-cron/pull/1.diff

Reply to this email directly or view it on GitHub: https://github.com/shawnchin/jquery-cron/pull/1

shawnchin commented 13 years ago

Actually, that looks straight-forward enough. Will try an auto-merge.

RikWaspcroft commented 12 years ago

That's a great control you've built there!
I am currently creating schedules with it and then processing them using Quartz.Net.

What might be of interest is that the source for Quartz.Net is freely available and includes the class CronExpression.cs which is what parses the cron expression accordingly. I notice that in your cron.js file that the expressions are interpreted from regular expressions, that although concise can be tedious to get working for all scenarios. It might be worth converting the CronExpression.cs file to js using something like jsc and cleaning it up. Admittedly it would make the cron.js file possibly double the size, but then would cover all cron's types.

If I had time I would... and maybe will. Will let you know if I do.

I notice that the cron for every minute "* * * * " does not get handled by Quartz.Net, I think the equivalent is "0 * * * \ ?" haven't figured out if this is a problem with Quartz or the control? (I'm new to cron expressions).

A common requirement our end is to cater for: every x days, every x weeks and every x months. i.e. much like that chap has done extending your control to cater for every x mins.

One small bug - 31th... should be 31st - tiny change to:

    if (i == 1 || i == 21) { var suffix = "st"; }

to be...

    if (i == 1 || i == 21 || i == 31) { var suffix = "st"; }
shawnchin commented 12 years ago

@RikWaspcroft Many thanks for getting in touch. It’s nice to know that the project is useful to others.

The cron expression parser in Quartz.Net looks very comprehensive. Thanks for pointing it out. I am tempted by a JS port of that, but I am also reminded that the whole idea behind jquery-cron was to provide an simple yet intuitive interface for users to select common combinations without the need to learn cron expressions. It was never meant to cover all possible cron values.

Perhaps we could consider an “advanced mode” version that allows more flexibility in the generation of expressions. The tricky bit is designing a UI that is usable enough to justify its existence. When reviewing several existing cron interfaces in the past, I found that apart from simple expressions it was often easier to write the expression by hand than navigate the interface.

I notice that the cron for every minute "* * * * " does not get handled by Quartz.Net, I think the equivalent is "0 * * * \ ?" haven't figured out if this is a problem with Quartz or the control? (I'm new to cron expressions).

No, 0 * * * * means every hour on the hour, as in 1:00, 2:00, 3:00, etc...

A common requirement is to cater for: every x days, every x weeks and every x months. i.e. much like that chap has done extending your control to cater for every x mins.

Yes, that is certainly on the books. I’ll tackle that when I next get a chance to spend more time on this project.

One small bug - 31th... should be 31st

Oops. Fixed in latest commit (63597f28f908824efb32aeb34c9704206cf200ba). Thanks.

Regards, Shawn

RikWaspcroft commented 12 years ago

Hi Shawn,

Thank-you for the reply. Great to hear the project is still being worked on. I think the control is great.

Regarding all cron expressions. Multi-select dropdowns could be used, for e.g. Every monday, tuesday and thursday at 9:00am. Perhaps include a bitwise property setting that switches mode to multi-select for day and/or week... as you mentioned, like an advanced mode. That way could have every jan, and feb on 5th and 7th at 9:45am.

In list of day in month, could add option "last day".

I guess if a list of bank holidays was supplied by the user, you could also include option; nearest working day or last/first working day of month.

These ideas, hopefully won't affect the usability of the control.

Some ideas on my way home on the bus ( some of which are not ones I particularly need for what I am doing, but is sure to be useful )

Thanks for the reply. I look forward to seeing the developments and will submit to you any changes that I do that might be useful.

Regards, Rik

Sent from my iPhone

On 9 Feb 2012, at 09:19, Shawn Chin reply@reply.github.com wrote:

@RikWaspcroft Many thanks for getting in touch. It’s nice to know that the project is useful to others.

The cron expression parser in Quartz.Net looks very comprehensive. Thanks for pointing it out. I am tempted by a JS port of that, but I am also reminded that the whole idea behind jquery-cron was to provide an simple yet intuitive interface for users to select common combinations without the need to learn cron expressions. It was never meant to cover all possible cron values.

Perhaps we could consider an “advanced mode” version that allows more flexibility in the generation of expressions. The tricky bit is designing a UI that is usable enough to justify its existence. When reviewing several existing cron interfaces in the past, I found that apart from simple expressions it was often easier to write the expression by hand than navigate the interface.

I notice that the cron for every minute "* * * * " does not get handled by Quartz.Net, I think the equivalent is "0 * * * \ ?" haven't figured out if this is a problem with Quartz or the control? (I'm new to cron expressions).

No, 0 * * * * means every hour on the hour, as in 1:00, 2:00, 3:00, etc...

A common requirement is to cater for: every x days, every x weeks and every x months. i.e. much like that chap has done extending your control to cater for every x mins.

Yes, that is certainly on the books. I’ll tackle that when I next get a chance to spend more time on this project.

One small bug - 31th... should be 31st

Oops. Fixed in latest commit (63597f28f908824efb32aeb34c9704206cf200ba). Thanks.

Regards, Shawn


Reply to this email directly or view it on GitHub: https://github.com/shawnchin/jquery-cron/pull/1#issuecomment-3884340