| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

past_date

#include "sfldate.h"
void
past_date (long *date, long *time, long days, long csecs)

Synopsis

Calculates a past date and time from the date and time specified, minus an interval specified in days and 1/100th seconds. The date can be any date since some distant epoch (around 1600). If the date and time arguments are both zero, the current date and time are used. Either date and time arguments may be null.

Source Code - (sfldate.c)

{
    long
        dummy_date = 0,
        dummy_time = 0;

    if (date == NULL)
        date = &dummy_date;
    if (time == NULL)
        time = &dummy_time;

    /*  Set date and time to NOW if necessary                                */
    if (*date == 0 && *time == 0)
      {
        *date = date now ();
        *time = time now ();
      }
    /*  Get past date in days and centiseconds                               */
    days  = date to days  (*date) - days;
    csecs = time to csecs (*time) - csecs;

    /*  Normalise underflow in centiseconds                                  */
    while (csecs < 0)
      {
        days--;
        csecs += INTERVAL_DAY;
      }

    /*  Convert date and time back into organised values                     */
    *date = days to date  (days);
    *time = csecs to time (csecs);
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation