home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!darwin.sura.net!sgiblab!troi!steve
- From: steve@dbaccess.com (Steve Suttles)
- Newsgroups: comp.lang.c
- Subject: Re: Recurring date/times?
- Message-ID: <130@mccoy.dbaccess.com>
- Date: 7 Jan 93 03:59:50 GMT
- References: <C0D387.HEH@panix.com>
- Organization: Cross Access Corp., Santa Clara, CA
- Lines: 45
- X-Newsreader: Tin 1.1 PL4
-
- 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.
- :
- Rob,
-
- You either need to redefine (restrict) the problem or implement the
- solution. As you stated it, you want an algorithm to manipulate dates.
- You want the capability of adding (signed) deltas, starting with
- today's or any numeric date, and advancing/retreating to a given day-of-the
- week. Many routines have been written to do date computations; your
- data structure, if you need to retain all these capabilities, is forced
- to be a codification of the calls necessary to do these manipulations.
- You can probably get by with a paired list: What to do and what to do it
- with, for as many steps as you want:
- (code for) start_with_fixed_date, (value for) November 1
- (code for) advance_to_DOW, (code for) Tuesday
- (code for) advance_by_delta, (value for) -7
- (code for) stop_processing, (no parameter required)
- would give you some warning for election day. Then you need to interpret
- this list and deal with the values.
-
- The other thing you could codify is the checks to make:
- (code for) compare_DOW, (code for) Tuesday
- (code for) compare_day_of_month_less_than, (value for) 3
- You can quit after an untrue condition, or after a true one, or whichever;
- to be truly flexible, you'd basically have to implement an RPN notation
- with operators for "get DOW" and "load DOW constant" and all the comparison
- (and boolean) and arithmetic operators.
-
- And of course, you could restrict the scope of the problem--that you only
- check day-of-the-week and the range of day-of-the-month, for example.
-
- What you are asking for is very specific and not likely to pre-exist...
-
- sas
- --
- Steve Suttles Internet: steve@dbaccess.com Dr. DCL is IN!
- CROSS ACCESS Corporation UUCP: {uunet,sgiblab}!troi!steve Yo speako TECO!
- 2900 Gordon Ave, Suite 100 fax: (408) 735-0328 Talk data to me!
- Santa Clara, CA 95051-0718 vox: (408) 735-7545 HA! It's under 4 lines NOW!
-