1. 'Prime Time' calculator
- Posted by Pete <pete_stoner at btconnect.com> Oct 25, 2004
- 679 views
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..
2. Re: 'Prime Time' calculator
- Posted by Pete <pete_stoner at btconnect.com> Oct 25, 2004
- 526 views
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?
3. Re: 'Prime Time' calculator
- Posted by Pete <pete_stoner at btconnect.com> Oct 25, 2004
- 512 views
- Last edited Oct 26, 2004
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
4. Re: 'Prime Time' calculator
- Posted by Derek Parnell <ddparnell at bigpond.com> Oct 25, 2004
- 480 views
- Last edited Oct 26, 2004
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
5. Re: 'Prime Time' calculator
- Posted by "Kat" <gertie at visionsix.com> Oct 26, 2004
- 489 views
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
6. Re: 'Prime Time' calculator
- Posted by Pete <pete_stoner at btconnect.com> Oct 26, 2004
- 489 views
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
7. Re: 'Prime Time' calculator
- Posted by cklester <cklester at yahoo.com> Oct 26, 2004
- 486 views
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.
8. Re: 'Prime Time' calculator
- Posted by irv mullins <irvm at ellijay.com> Oct 26, 2004
- 496 views
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