HP3000-L Archives

September 2002, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Reply To:
[log in to unmask][log in to unmask] "If at first you don't succeed...
Web : http://www.hp3000links.com Don't take up sky-diving !"
"All your HP e3000 resources on the Net"
(Mirror: http://www.users.totalise.co.uk/~jdunlop/index1.htm)

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *44_26Sep200214:07:[log in to unmask]
Date:
Thu, 26 Sep 2002 14:12:48 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (64 lines)
Is there an elegant algorithm to figure out if a date is a holiday?

Businesses tend to recognize two types of holidays (those of you outside the
U.S. can brag about your more generous allocations of holidays). There are
those that fall on the same date every year: New Years Day, Independence
Day, and Christmas in the U.S. Those are easy enough to test for (ignoring
for the moment the problem of processing that can either start before
midnight, or continue after, which can probably be handled by also checking
the hour).

The U.S. has those that fall on some occurrence of a day of the week within
its month. Now, those can all be handled by testing for a month, day of
week, and range of days (probably in that order). Memorial Day is May,
Monday, and day-of-month greater than or equal to 25. Labor Day is
September, Monday, and day-of-month less than or equal to 7. Thanksgiving is
November, Thursday, and greater than or equal to 22 and less than or equal
to 28. The day after Thanksgiving is Friday, and greater than or equal to 23
and less than or equal to 29 (this year, it's the fifth Friday, not the
fourth Friday, since November begins on a Friday. You've been warned...).

So, short of three simple IFs, plus four IFs with three or four ANDS, is
there a more elegant solution?

The only other idea I've been able to come up with is to grep for some
cobbled together date string(s) in a holiday file, which contains:
JAN 1
MON MAY 25 ... MON MAY 31
JUL 4
MON SEP 01 ... MON SEP 07
THU NOV 22 ... THU NOV 28
FRI NOV 23 ... FRI NOV 29
DEC 25
or some such.

I know that some businesses are closed for holidays based on religious or
ecclesiastical lunar calendars. And, I have seen algorithms for calculating
some of these. The latter solution seems more likely to accommodate those.

            CALCULATE-LONG-TANGENT.
One of my first, small victories in my first 3000 shop was finding and
fixing the bug in their Byzantine* set of day-of-the-week batch jobs, each
of which ended by copying the next day's named job stream to
SCHEDULE.group.account. This experience reinforced my belief in small,
modular, reasonably structured scripting, even if the notations and
conventions are not intuitively obvious to the most casual user. It also
reminded me what surprises await us when we do not think through our logic
carefully enough... In fact, I still tell the story of the Sunday night /
Monday morning after Thanksgiving, when an operator in the Corporate office
killed the NS connection feeding data to our system, so she could run a
non-critical backup job. Twice... probably one of the worst days of work
I've had, in which no one gave me any flak for the resulting problems... You
can kill the bugs, but not the operators...
            CALCULATE-LONG-TANGENT-EXIT.

* in the sense of "Highly complicated; intricate and involved", not "Of or
relating to the Byzantine Empire" nor "Of the Eastern Orthodox Church".
<http://www.dictionary.com/search?q=byzantine>.

Greg Stigers
http://www.cgiusa.com

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2