home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19266 < prev    next >
Encoding:
Text File  |  1993-01-05  |  3.2 KB  |  82 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!noc.near.net!gateway!miki!nail!geiser
  3. From: geiser@pictel.com (Wayne Geiser)
  4. Subject: Re: Recurring date/times?
  5. Message-ID: <1993Jan5.175737.23724@miki.pictel.com>
  6. Sender: geiser@nail (Wayne Geiser)
  7. Nntp-Posting-Host: nail
  8. Organization: PictureTel Corporation
  9. References:  <C0D387.HEH@panix.com>
  10. Date: Tue, 5 Jan 1993 17:57:37 GMT
  11. Lines: 69
  12.  
  13. In article <C0D387.HEH@panix.com>, rmah@panix.com (Robert Mah) writes:
  14. |> Anyone have any suggestions on good data structures for representing 
  15. |> recurring dates and times.  That is, things like "the first teusday
  16. |> of every month" or "three days before the end of every month", etc.
  17. |> 
  18. |> I'm looking for something flexible and compact that I can easily check
  19. |> to see if a given date/time falls on the recurring date/time.
  20. |> 
  21. |> Thanks,
  22. |> Rob
  23. |> 
  24. |> -- 
  25. |> [--------------------------------------------------]
  26. |> [  Robert S. Mah   |  "Every day an adventure,     ]
  27. |> [  rmah@panix.com  |   every moment a challenge."  ]
  28. |> [--------------------------------------------------]
  29.  
  30. There are actually very few forms that one needs to represent a great variety of
  31. date forms.
  32.  
  33. weekday on or before date - This gives you things like 2nd Tuesday
  34. date + days
  35. date - days               - This gives you things like 3 days before end
  36.                             of month (i.e., 4 days before 1st of next month,
  37.                             so you don't have to know how many days are in the
  38.                             month)
  39. everyday
  40.  
  41. I used this type of date logic in a shareware program I wrote called "On This
  42. Day" (look for otd??.zip on simtel, garbo, and other quality servers :-)).  My
  43. dates were expressed in text and look something like:
  44.  
  45. m    Monthly event (Gregorian number)
  46. m/d    Gregorian event with no associated year
  47. m/d/y    Gregorian event
  48. Hm/d    Jewish event (i.e., Hebrew calendar)
  49. HFm/d   Jewish fast day (special rules apply)
  50. Im/d    Islamic event
  51. Jm/d    Julian event
  52. *       Every day
  53. M(m/d)  Monday on or before date (T, W, R, F, S, U are the other days of the
  54.         week)
  55. E       Easter
  56. m/d+days Add number of days to the date
  57. m/d-days Subtract number of days from date
  58.  
  59. There are lots of permutations:
  60.  
  61. E+60    Gives you Corpus Christi (Thursday following Trinity Sunday)
  62. H1/1-16 Gives Purim (needs odd calculation because of leap months in the
  63.         Hebrew calendar
  64. W(*)    Every Wednesday
  65. M(1/31) Australia Day Observed (Monday on or after 1/26).
  66. *+1     Tomorrow
  67.  
  68. Anyway, you get the idea.  Possibly you can take the same ideas and use them
  69. in designing your data structures.  I've found them to be remarkably flexible.
  70. -- 
  71. **********************************************************************
  72. * Wayne Geiser ("Drivel King")           Voice:    (508) 977-8253    *
  73. * PictureTel Corporation                 FAX:      (508) 532-6893    *
  74. * One Corporation Way                    Internet: geiser@pictel.com *
  75. * Peabody, MA      01960                 CIS:      70313,3615        *
  76. *                                        GEnie:    W.GEISER          *
  77. **********************************************************************
  78. "... I've got to figure out how to make it clearer that we are for the
  79.  things that I have advocated that would help."
  80.  
  81.         - George Bush.
  82.