home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!noc.near.net!gateway!miki!nail!geiser
- From: geiser@pictel.com (Wayne Geiser)
- Subject: Re: Recurring date/times?
- Message-ID: <1993Jan5.175737.23724@miki.pictel.com>
- Sender: geiser@nail (Wayne Geiser)
- Nntp-Posting-Host: nail
- Organization: PictureTel Corporation
- References: <C0D387.HEH@panix.com>
- Date: Tue, 5 Jan 1993 17:57:37 GMT
- Lines: 69
-
- In article <C0D387.HEH@panix.com>, rmah@panix.com (Robert Mah) writes:
- |> Anyone have any suggestions on good data structures for representing
- |> recurring dates and times. That is, things like "the first teusday
- |> of every month" or "three days before the end of every month", etc.
- |>
- |> I'm looking for something flexible and compact that I can easily check
- |> to see if a given date/time falls on the recurring date/time.
- |>
- |> Thanks,
- |> Rob
- |>
- |> --
- |> [--------------------------------------------------]
- |> [ Robert S. Mah | "Every day an adventure, ]
- |> [ rmah@panix.com | every moment a challenge." ]
- |> [--------------------------------------------------]
-
- There are actually very few forms that one needs to represent a great variety of
- date forms.
-
- weekday on or before date - This gives you things like 2nd Tuesday
- date + days
- date - days - This gives you things like 3 days before end
- of month (i.e., 4 days before 1st of next month,
- so you don't have to know how many days are in the
- month)
- everyday
-
- I used this type of date logic in a shareware program I wrote called "On This
- Day" (look for otd??.zip on simtel, garbo, and other quality servers :-)). My
- dates were expressed in text and look something like:
-
- m Monthly event (Gregorian number)
- m/d Gregorian event with no associated year
- m/d/y Gregorian event
- Hm/d Jewish event (i.e., Hebrew calendar)
- HFm/d Jewish fast day (special rules apply)
- Im/d Islamic event
- Jm/d Julian event
- * Every day
- M(m/d) Monday on or before date (T, W, R, F, S, U are the other days of the
- week)
- E Easter
- m/d+days Add number of days to the date
- m/d-days Subtract number of days from date
-
- There are lots of permutations:
-
- E+60 Gives you Corpus Christi (Thursday following Trinity Sunday)
- H1/1-16 Gives Purim (needs odd calculation because of leap months in the
- Hebrew calendar
- W(*) Every Wednesday
- M(1/31) Australia Day Observed (Monday on or after 1/26).
- *+1 Tomorrow
-
- Anyway, you get the idea. Possibly you can take the same ideas and use them
- in designing your data structures. I've found them to be remarkably flexible.
- --
- **********************************************************************
- * Wayne Geiser ("Drivel King") Voice: (508) 977-8253 *
- * PictureTel Corporation FAX: (508) 532-6893 *
- * One Corporation Way Internet: geiser@pictel.com *
- * Peabody, MA 01960 CIS: 70313,3615 *
- * GEnie: W.GEISER *
- **********************************************************************
- "... I've got to figure out how to make it clearer that we are for the
- things that I have advocated that would help."
-
- - George Bush.
-