Date2Secs
Date2Secs Convert a DateTimeRec into a "raw" seconds value #include <OSUtils.h> Operating System Utilities
DateTimeRec *dtrp ; contains day, month, year, hour, etc. unsigned long *secs ; receives "raw" seconds since 1/1/1904 The result could be used in comparing two dates or setting the clock.
dtrp is the address of a 14-byte DateTimeRec structure. The dayOfWeek field is ignored. The other fields are used (in a flexible manner) to
calculate the value for secs.
secs is the address of a 4-byte unsigned long int. Upon return, it will
contain a "raw" seconds value corresponding to the values of the
Notes: Date2Secs is a handy intermediate step for generating a textual representation of a date (see IUDateString). It is also useful for adding, subtracting, or comparing two dates/times. For instance:
# define SECS_PER_DAY (60*60*24)
short elapsedDays;
elapsedDays = (shipSecs-ivcSecs)/SECS_PER_DAY;
Although the year and month fields of the DateTimeRec should be valid, this call is flexible about other fields. Thus, you can convert an "invalid" date
(such as January 200 or today+30) to "raw" seconds, and back to date/time
to make it valid. For instance:
theDate.day +=30; /* March 45 */
Since the base date for the any "raw seconds" value is 1/1/1904 and since
secs is a 32-bit value, you won't be able to calculate with dates beyond
Feb. 6, 2040.