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

 

date_to_days

#include "sfldate.h"
long
date_to_days (long date)

Synopsis

Converts the date into a number of days since a distant but unspecified epoch. You can use this function to calculate differences between dates, and forward dates. Use days to date() to calculate the reverse function. Author: Robert G. Tantzen, translated from the Algol original in Collected Algorithms of the CACM (algorithm 199). Original translation into C by Nat Howard, posted to Usenet 5 Jul 1985.

Source Code - (sfldate.c)

{
    long
        year    = GET_YEAR    (date),
        century = GET_CENTURY (date),
        month   = GET_MONTH   (date),
        day     = GET_DAY     (date);

    if (month > 2)
        month -= 3;
    else
      {
        month += 9;
        if (year)
            year--;
        else
          {
            year = 99;
            century--;
          }
      }
    return ((146097L * century)    / 4L +
            (1461L   * year)       / 4L +
            (153L    * month + 2L) / 5L +
                       day   + 1721119L);
}

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