[comp.lang.icon] Time and Date Routines

tenaglia@mis.mcw.edu ("Chris Tenaglia - 257-8765") (10/10/90)

Perhaps I didn't look close enough at the IPL, but I am interested in time
and date manipulation routines. One the outside it sounds simple. Here're
the specs.

procedure dow(d)     : Day of week. Should return either 1 through 7 or
                       Sunday through Saturday.

procedure difdate(d1,d2,uom) : Subtracts date d1 from date d2. uom is the
                               unit of measure for the result as seconds,
                               minutes, hours, days, weeks, months, years.

procedure future(d1,d2,uom)  : Adds duration d2 to date d1, yielding answer.
                               duration in unit of measure uom, being either
                               seconds, minutes, hours, days, weeks, months,
                               years.

Date formats => YYYY-MMM-DD:HH:MM:SS
                Month Day, Year HH:MM:SS

The routines should be smart enough to handle leap years, and be able to make
due with partial specs. 1990-oct-04 would default with 00:00:00. oct-04 would
also assume the current year. Examples...

          difdate("oct-04","oct-16","day")   returns 12
          future("oct-02",6,"month")         returns "1991-apr-02:00:00:00"
          dow("oct-9")                       returns 3 or Tuesday

I think these might make a good addition to the IPL. Perhaps others have better
ideas. Is date manipulation of interest to anyone else? I haven't developed the
bodies of the procedures yet, but wonder if someone else has already?

Chris Tenaglia (System Manager)
Medical College of Wisconsin
8701 W. Watertown Plank Rd.
Milwaukee, WI 53226
(414)257-8765
tenaglia@mis.mcw.edu, mcwmis!tenaglia