Date Calculator for Forms

by "Warren R. Glore" <wglore(at)wichita.fn.net>

 Date:  Sun, 22 Oct 2000 15:20:51 -0500
 To:  "HWG Techniques" <hwg-techniques(at)hwg.org>
  todo: View Thread, Original
Greetings,

I have a problem with a form that I am developing and need some help on it.
I am designing a form that allows the user to put an expiration date on it.
They are then going to decide if they want a warning sent out before the
expiration date. If they do, they will choose the number of units and pick
the units ( days, weeks, and months) to be warned of the expiration date
approaching. This needs to be put into an "at" job on a unix server to
notify the customer of his/her expiration date. All the form work great and
the variables are filled properly. However, the "at" jobs do not accept -
days/weeks/months. They only accept + days, weeks, months. I need some type
of script that accept the expiration date, the interval (a positive
integer), and the unit (day, week, month) and then return the new date.

I have tried a countdown script that will give me the number of days from
here to the expiration date and then figured how many days to subtract for
the days, weeks, months, and then do the "at" job with now "+ x days", but
due to server fail-over capabilities, the warning date has to be saved in a
file so this technique will not work.

Has anyone come across a script such as this or has something close that can
be easily modified.

PS. The script has to take into account Leap years and subtracting months
must end up on the same day of the month (ie May 20 - 2 month = Mar 20)
regardless of how many days in the month.

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA