1. 'Prime Time' calculator

Hi All,
     As an addition to an existing program I need to come up with a 
function to tell me if the current day/time is in working hours 
(Prime Time), using time() it's easy for < 9.00 or > 17.30 and a Saturday 
or Sunday, however it is slightly more tricky if it is a public holiday.
Fixed days like Christmas shouldn't be too bad (remembering to allow if 
it falls on a weekend it shifts to a weekday) but 'movable' dates like 
Easter are another story..

new topic     » topic index » view message » categorize

2. Re: 'Prime Time' calculator

Sorry, hit enter a little soon..
  I should add I need to handle this not only for the UK but also for the
Netherlands and South Africa..
  I can't find an existing include in the archives, does anyone have
anything already or care to help?

new topic     » goto parent     » topic index » view message » categorize

3. Re: 'Prime Time' calculator

I wrote:
> 
> Sorry, hit enter a little soon..
>   I should add I need to handle this not only for the UK but also for the
> Netherlands and South Africa..
>   I can't find an existing include in the archives, does anyone have
> anything already or care to help?
> 
I'm getting somewhere(!?), I now have a formula to calculate Easter Day
(courtesy of Carl Friedrich Gauss)

integer a, b, c, d, e
sequence TimeAndDate, Easter
TimeAndDate = date() 
  year = TimeAndDate[1] + 1900
a = remainder(year, 19)
b = remainder(year, 4)
c = remainder(year, 7)

d = remainder((19*a + 24), 30)
e = remainder((2*b + 4*c + 6*d + 5), 7)

if d+e < 10 then Easter = (d+e+22) & " March"
else Easter = (d+e-9) & " April"
end if


Pete

new topic     » goto parent     » topic index » view message » categorize

4. Re: 'Prime Time' calculator

Pete wrote:
> 
> I wrote:
> > 
> > Sorry, hit enter a little soon..
> >   I should add I need to handle this not only for the UK but also for the
> > Netherlands and South Africa..
> >   I can't find an existing include in the archives, does anyone have
> > anything already or care to help?
> > 
> I'm getting somewhere(!?), I now have a formula to calculate Easter Day
> (courtesy of Carl Friedrich Gauss)

Experience has made me think that the easiest way is to let the user define
which days (and partial days) are non-work periods. It is a small task to 
provide a method for users to maintain a 'non-work' calendar and to use
that calendar in your application.

Each culture, region, and organistion has greatly varying definitions
of what is a non-work period. It is too hard to get it right algorithmically.
Just let the users tell instead.

-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

5. Re: 'Prime Time' calculator

On 25 Oct 2004, at 12:51, Pete wrote:

> 
> 
> posted by: Pete <pete_stoner at btconnect.com>
> 
> Hi All,
>      As an addition to an existing program I need to come up with a 
> function to tell me if the current day/time is in working hours 
> (Prime Time), using time() it's easy for < 9.00 or > 17.30 and a Saturday 
> or Sunday, however it is slightly more tricky if it is a public holiday.
> Fixed days like Christmas shouldn't be too bad (remembering to allow if 
> it falls on a weekend it shifts to a weekday) but 'movable' dates like 
> Easter are another story..

Will you be doing all the pagan, jewish, hindu, islamic, and secular 
holidays
too?

Kat

new topic     » goto parent     » topic index » view message » categorize

6. Re: 'Prime Time' calculator

Kat wrote:
> 
> On 25 Oct 2004, at 12:51, Pete wrote:
> 
> > 
> > posted by: Pete <pete_stoner at btconnect.com>
> > 
> > Hi All,
> >      As an addition to an existing program I need to come up with a 
> > function to tell me if the current day/time is in working hours 
> > (Prime Time), using time() it's easy for < 9.00 or > 17.30 and a Saturday 
> > or Sunday, however it is slightly more tricky if it is a public holiday.
> > Fixed days like Christmas shouldn't be too bad (remembering to allow if 
> > it falls on a weekend it shifts to a weekday) but 'movable' dates like 
> > Easter are another story..
> 
> Will you be doing all the pagan, jewish, hindu, islamic, and secular 
> holidays
> too?
> 
> Kat
> 
 No, this is for a robot prog running on its own PC (in a locked m/c room)
24 by 7, it is handling stuff for various countries, however the UK, 
Netherlands and South Africa need some special handling during their public 
holidays. Been thinking more about this and I may just 'cop out' and
give it a list of actual dates for each country covering the next few 
years, after that the prog will probably be obsolete anyway!!

Pete

new topic     » goto parent     » topic index » view message » categorize

7. Re: 'Prime Time' calculator

Kat wrote:
> On 25 Oct 2004, at 12:51, Pete wrote:
> > posted by: Pete <pete_stoner at btconnect.com>
> > Hi All,
> > Fixed days like Christmas shouldn't be too bad (remembering to allow if 
> > it falls on a weekend it shifts to a weekday) but 'movable' dates like 
> > Easter are another story..
> 
> Will you be doing all the pagan, jewish, hindu, islamic, and secular 
> holidays too?

Nobody cares about those holidays. Well, except heathen.

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

P.S. I'm kiddin'! sheesh.

new topic     » goto parent     » topic index » view message » categorize

8. Re: 'Prime Time' calculator

Pete wrote:

>  No, this is for a robot prog running on its own PC (in a locked m/c room)
> 24 by 7, it is handling stuff for various countries, however the UK, 
> Netherlands and South Africa need some special handling during their public 
> holidays. Been thinking more about this and I may just 'cop out' and
> give it a list of actual dates for each country covering the next few 
> years, after that the prog will probably be obsolete anyway!!

Considering that all holidays are subject to change by those in 
charge of such things, whether they be political leaders or religious 
leaders, there's no point in trying to automate this.

Irv

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu