Category : Files from Magazines
Archive   : CUJ9302.ZIP
Filename : 1102124B

 
Output of file : 1102124B contained in archive : CUJ9302.ZIP
// date.cpp: Implement the Date class

#include "date.h"

inline int isleap(int y)
{return y%4 == 0 && y%100 != 0 || y%400 == 0;}

static int Dtab[2][13] =
{
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
};

Date * Date::interval(const Date& d2)
{
static Date result;
int months, days, years, prev_month;

// Compute the interval - assume d1 precedes d2
years = d2.year - year;
months = d2.month - month;
days = d2.day - day;

// Do obvious corrections (days before months!)
//
// This is a loop in case the previous month is
// February, and days < -28.
prev_month = d2.month - 1;
while (days < 0)
{
// Borrow from the previous month
if (prev_month == 0)
prev_month = 12;
--months;
days += Dtab[isleap(d2.year)][prev_month--];
}

if (months < 0)
{
// Borrow from the previous year
--years;
months += 12;
}

/* Prepare output */
result.month = months;
result.day = days;
result.year = years;
return &result;
}



  3 Responses to “Category : Files from Magazines
Archive   : CUJ9302.ZIP
Filename : 1102124B

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/