home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19418 < prev    next >
Encoding:
Internet Message Format  |  1993-01-08  |  2.6 KB

  1. Path: sparky!uunet!gatech!darwin.sura.net!sgiblab!troi!steve
  2. From: steve@dbaccess.com (Steve Suttles)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Recurring date/times?
  5. Message-ID: <130@mccoy.dbaccess.com>
  6. Date: 7 Jan 93 03:59:50 GMT
  7. References: <C0D387.HEH@panix.com>
  8. Organization: Cross Access Corp., Santa Clara, CA
  9. Lines: 45
  10. X-Newsreader: Tin 1.1 PL4
  11.  
  12. rmah@panix.com (Robert Mah) writes:
  13. : Anyone have any suggestions on good data structures for representing 
  14. : recurring dates and times.  That is, things like "the first teusday
  15. : of every month" or "three days before the end of every month", etc.
  16. : I'm looking for something flexible and compact that I can easily check
  17. : to see if a given date/time falls on the recurring date/time.
  18. Rob,
  19.  
  20. You either need to redefine (restrict) the problem or implement the
  21. solution.  As you stated it, you want an algorithm to manipulate dates.
  22. You want the capability of adding (signed) deltas, starting with
  23. today's or any numeric date, and advancing/retreating to a given day-of-the
  24. week.  Many routines have been written to do date computations; your
  25. data structure, if you need to retain all these capabilities, is forced
  26. to be a codification of the calls necessary to do these manipulations.
  27. You can probably get by with a paired list: What to do and what to do it
  28. with, for as many steps as you want: 
  29.     (code for) start_with_fixed_date, (value for) November 1
  30.     (code for) advance_to_DOW, (code for) Tuesday
  31.     (code for) advance_by_delta, (value for) -7
  32.     (code for) stop_processing, (no parameter required)
  33. would give you some warning for election day.  Then you need to interpret
  34. this list and deal with the values.
  35.  
  36. The other thing you could codify is the checks to make:
  37.     (code for) compare_DOW, (code for) Tuesday
  38.     (code for) compare_day_of_month_less_than, (value for) 3
  39. You can quit after an untrue condition, or after a true one, or whichever;
  40. to be truly flexible, you'd basically have to implement an RPN notation
  41. with operators for "get DOW" and "load DOW constant" and all the comparison
  42. (and boolean) and arithmetic operators.
  43.  
  44. And of course, you could restrict the scope of the problem--that you only
  45. check day-of-the-week and the range of day-of-the-month, for example.
  46.  
  47. What you are asking for is very specific and not likely to pre-exist...
  48.  
  49. sas
  50. -- 
  51. Steve Suttles                Internet:  steve@dbaccess.com      Dr. DCL is IN!
  52. CROSS ACCESS Corporation     UUCP: {uunet,sgiblab}!troi!steve  Yo speako TECO!
  53. 2900 Gordon Ave, Suite 100   fax: (408) 735-0328              Talk data to me!
  54. Santa Clara, CA 95051-0718   vox: (408) 735-7545   HA! It's under 4 lines NOW!
  55.