You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Peter Donald <do...@apache.org> on 2001/08/01 06:21:53 UTC
Re: CronTimeTrigger bug
Hi,
I finally got a chance to look at this - soz for the delay ;)
On Mon, 30 Jul 2001 01:10, Bernhard Huber wrote:
> I was testing CronTimeTrigger and found a bug:
> Assume today is 29th July 2001
> You set a cron time trigger to 5th Feb 2002, then
> CronTimeTrigger will set next time running to
> 5th March 2002, not 5th Feb 2002
hmmm. I can't seem to reproduce this. Maybe I don't understand something ;)
I have added a method testRolledMonthDay() to
org.apache.avalon.cornerstone.services.scheduler.test.CronTimeTriggerTestlet
You can run the test via ./build.sh test
Does it function correctly at your end ? (could be something to do with
localization if it doesn't).
Also have I understood problem correctly ? ;)
> In order to solve that problem, I check if the m_month has enough
> day,if not i set next to max days of m_month, like:
hmm. I am not sure I get you. What you are saying is if we ask for day 29 in
a 28 day month then we should set it to 28? Makes sense to me.
However I can't see how it solves the above problem?
> if( -1 != m_month ) {
> // check if start: m_month, has enough days
> Calendar cal_month = (GregorianCalendar)next.clone();
> cal_month.set( Calendar.DAY_OF_MONTH, 1 );
> cal_month.set( Calendar.MONTH, m_month );
> int max_day_of_month = cal_month.getActualMaximum(
> Calendar.DAY_OF_MONTH );
> if (max_day_of_month < next.get( Calendar.DAY_OF_MONTH )) {
> next.set( Calendar.DAY_OF_MONTH, max_day_of_month );
> }
> // check if end
> next.set( Calendar.MONTH, m_month );
> if( -1 == m_hour ) next.set( Calendar.HOUR_OF_DAY, 0 );
> if( -1 == m_minute ) next.set( Calendar.MINUTE, 0 );
> }
I moved it down to after year is set so that you could also catch the case
where you explicitly set the year. Other than that it works great - thanks!
Cheers,
Pete
*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof." |
| - John Kenneth Galbraith |
*-----------------------------------------------------*
---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
Re: CronTimeTrigger bug
Posted by Peter Donald <do...@apache.org>.
On Wed, 1 Aug 2001 14:21, Peter Donald wrote:
> Hi,
>
> I finally got a chance to look at this - soz for the delay ;)
>
> On Mon, 30 Jul 2001 01:10, Bernhard Huber wrote:
> > I was testing CronTimeTrigger and found a bug:
> > Assume today is 29th July 2001
> > You set a cron time trigger to 5th Feb 2002, then
> > CronTimeTrigger will set next time running to
> > 5th March 2002, not 5th Feb 2002
>
> hmmm. I can't seem to reproduce this. Maybe I don't understand something ;)
Yes I did. I mistakenly tested thinking that months were 1 based rather than
zero based ;/
> > In order to solve that problem, I check if the m_month has enough
> > day,if not i set next to max days of m_month, like:
>
> hmm. I am not sure I get you. What you are saying is if we ask for day 29
> in a 28 day month then we should set it to 28? Makes sense to me.
>
> However I can't see how it solves the above problem?
I can see it now and have fixed it - thanks.
Cheers,
Pete
*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof." |
| - John Kenneth Galbraith |
*-----------------------------------------------------*
---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
Re: CronTimeTrigger bug
Posted by Peter Donald <do...@apache.org>.
Yup that was my error ;)
I sent another email saying oops but the server ahasn't passed it on just yet
;)
On Wed, 1 Aug 2001 15:28, Paul Hammant wrote:
> Is the original bug something to do with the months enumeration deep inside
> Date has 0 for Jan and 11 for Dec.
>
> Bernhard states "Assume today is 29th July 2001" in code did he/you code
> that as "Assume today is 2001-07-29" IYKWIM.
>
> - Paul
>
>
> --- Peter Donald <do...@apache.org> wrote: > Hi,
>
> > I finally got a chance to look at this - soz for the delay ;)
> >
> > On Mon, 30 Jul 2001 01:10, Bernhard Huber wrote:
> > > I was testing CronTimeTrigger and found a bug:
> > > Assume today is 29th July 2001...........
>
> =====
> Regards - Paul H
> ====
> CVS -1, Perforce +1
>
> ____________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
> or your free @yahoo.ie address at http://mail.yahoo.ie
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
--
Cheers,
Pete
*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof." |
| - John Kenneth Galbraith |
*-----------------------------------------------------*
---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
Re: CronTimeTrigger bug
Posted by Paul Hammant <pa...@yahoo.com>.
Is the original bug something to do with the months enumeration deep inside Date has 0 for Jan and
11 for Dec.
Bernhard states "Assume today is 29th July 2001" in code did he/you code that as "Assume today is
2001-07-29" IYKWIM.
- Paul
--- Peter Donald <do...@apache.org> wrote: > Hi,
>
> I finally got a chance to look at this - soz for the delay ;)
>
> On Mon, 30 Jul 2001 01:10, Bernhard Huber wrote:
> > I was testing CronTimeTrigger and found a bug:
> > Assume today is 29th July 2001...........
=====
Regards - Paul H
====
CVS -1, Perforce +1
____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie
---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org