Category : C++ Source Code
Archive   : WLIB.ZIP
Filename : WTIME.H

 
Output of file : WTIME.H contained in archive : WLIB.ZIP
#ifndef WTimeIncluded
#define WTimeIncluded

// copyright (c) 1992, 1993 by Paul Wheaton, Banana Programming
// 1916 Brooks #205, Missoula, MT 59801
//
// phone: (406)543-1928
// CompuServe: 72707,207
// Internet: [email protected]
// BBS: (406)543-8234 (The Montana Banana BBS)

#include

extern const char* MonthName[13]; // 0 is nothing, 1 is January
extern const char* WeekdayName[7]; // 0 is Monday

class JulianDate;

class Date
{
int Y,M,D; // Year, Month, Day
friend JulianDate;
public:
Date(int Year, int Month, int Day){Y=Year;M=Month;D=Day;}
// Some of you programming greenhorns may be offended at the order
// of these parameters - more than once it paid off for me to order
// my stuff this way - most significant value first.
Date(){Y=0;M=0;D=0;}
Date(const JulianDate&);
Date(const Date& X){Y=X.Y; M=X.M; D=X.D;}
Date(const char* Text);
int Year() const {return Y;}
String40 YearStr() const {return Form("@@@@",Y);}
int Month() const {return M;}
String40 MonthStr() const; // e.g. "January"
String40 MonthStr2() const; // e.g. "01" "02" ... "12"
String40 DayStr() const; // e.g. "01" "02" ... "31"
String40 FullDesc() const; // e.g. "Wednesday, September 24, 1965"
String40 ShortDesc() const; // e.g. "09-24-1965"
int Day() const {return D;}
int DOW() const;
String40 DayName() const; // e.g. "Monday"
String40 RelativePastStr() const;
void SetYear(int Year){Y=Year;}
void SetMonth(int Month){M=Month;}
void SetDay(int Day){D=Day;}
Bool Valid() const; // test to see if the date is a valid Gregorian day

void operator=(const JulianDate&);
void operator=(const Date& X){Y=X.Y; M=X.M; D=X.D;}

Bool operator==(const JulianDate&) const;
Bool operator<=(const JulianDate&) const;
Bool operator>=(const JulianDate&) const;
Bool operator!=(const JulianDate&) const;
Bool operator<(const JulianDate&) const;
Bool operator>(const JulianDate&) const;

JulianDate operator+(long Days) const;
JulianDate operator-(long Days) const;
long operator-(const JulianDate&) const;
JulianDate operator++(); // prefix operators
JulianDate operator--();
JulianDate operator++(int); // postfix operators
JulianDate operator--(int);
void operator+=(long Days);
void operator-=(long Days);
#ifdef MAJORBBS
void* operator new(size_t size){return malloc(size);}
void operator delete(void* p) {free(p);}
#endif
};

class Moment;

const long MinutesInADay=1440;

class JulianDate
{
long J; // number of days since Jan 1, 0000
friend Date;
friend class Moment;
public:
JulianDate(long JJ){J=JJ;}
JulianDate(int Year, int Month, int Day);
JulianDate(){J=0;}
JulianDate(const JulianDate& JJ){J=JJ.J;}
JulianDate(const Date&);
JulianDate(const Moment& M);// {J=long(M)/MinutesInADay;}
long Val(){return J;}
int Year() const;
int Month() const;
int Day() const;
int DOW() const {return int((J-2)%7);}
String40 DayName() const;
String40 FullDesc() const;
String40 ShortDesc(){return Date(*this).ShortDesc();}
String40 RelativePastStr(Bool AlphaDate=True) const;
void SetYear(int Year);
void SetMonth(int Month);
void SetDay(int Day);

void operator=(const JulianDate& JJ){J=JJ.J;}
void operator=(const Date&);

Bool operator==(const JulianDate& JJ) const {return Bool(J==JJ.J);}
Bool operator<=(const JulianDate& JJ) const {return Bool(J<=JJ.J);}
Bool operator>=(const JulianDate& JJ) const {return Bool(J>=JJ.J);}
Bool operator!=(const JulianDate& JJ) const {return Bool(J!=JJ.J);}
Bool operator<(const JulianDate& JJ) const {return Bool(J Bool operator>(const JulianDate& JJ) const {return Bool(J>JJ.J);}
Bool operator==(long JJ) const {return Bool(J==JJ);}
Bool operator<=(long JJ) const {return Bool(J<=JJ);}
Bool operator>=(long JJ) const {return Bool(J>=JJ);}
Bool operator!=(long JJ) const {return Bool(J!=JJ);}
Bool operator<(long JJ) const {return Bool(J Bool operator>(long JJ) const {return Bool(J>JJ);}
friend Bool operator==(long J,const JulianDate& JJ) {return Bool(J==JJ.J);}
friend Bool operator<=(long J,const JulianDate& JJ) {return Bool(J<=JJ.J);}
friend Bool operator>=(long J,const JulianDate& JJ) {return Bool(J>=JJ.J);}
friend Bool operator!=(long J,const JulianDate& JJ) {return Bool(J!=JJ.J);}
friend Bool operator<(long J,const JulianDate& JJ) {return Bool(J friend Bool operator>(long J,const JulianDate& JJ) {return Bool(J>JJ.J);}

JulianDate operator+(long Days) const;
JulianDate operator-(long Days) const;
long operator-(const JulianDate& JJ) const {return J-JJ.J;}
JulianDate operator++(){J++; return *this;}
JulianDate operator--(){J--; return *this;}
JulianDate operator++(int);
JulianDate operator--(int);
void operator+=(long Days){J+=Days;}
void operator-=(long Days){J-=Days;}
#ifdef MAJORBBS
void* operator new(size_t size){return malloc(size);}
void operator delete(void* p) {free(p);}
#endif
};

Date Today();

class Moment;

class Time // still working on this one
{
int H; // 0..23
int M; // 0..59
int S; // 0..59
public:
Time(int Hr=0, int Min=0, int Sec=0){H=Hr; M=Min; S=Sec;}
Time(const Moment&);
String40 Desc();
String40 ShortDesc();
#ifdef MAJORBBS
void* operator new(size_t size){return malloc(size);}
void operator delete(void* p) {free(p);}
#endif
};

Time CurTime();

class Moment
{
long M;
public:
Moment(long X=0){M=X;}
Moment(Moment& MM){M=MM.M;}
Moment(const JulianDate& J){M=J.J*MinutesInADay;}
Moment(const JulianDate& J, const Time&);
Moment(const JulianDate& J, int Hour, int Minute);
operator long() const {return M;}
//operator JulianDate();//{return JulianDate(M/MinutesInADay);}
int MinCount(){return int(M%MinutesInADay);}
void SetMinCount(int X){M=M-MinCount()+X;}
void operator=(long X){M=X;}
void operator=(Moment MM){M=MM.M;}
// comparison operators
Bool operator==(long X) const {return (M==X);}
Bool operator!=(long X) const {return (M!=X);}
Bool operator<=(long X) const {return (M<=X);}
Bool operator>=(long X) const {return (M>=X);}
Bool operator<(long X) const {return (M Bool operator>(long X) const {return (M>X);}
Bool operator==(Moment X) const {return (M==X.M);}
Bool operator!=(Moment X) const {return (M!=X.M);}
Bool operator<=(Moment X) const {return (M<=X.M);}
Bool operator>=(Moment X) const {return (M>=X.M);}
Bool operator<(Moment X) const {return (M Bool operator>(Moment X) const {return (M>X.M);}
friend Bool operator==(long X, Moment M) {return (X==Mend Bool operator==(long X, Momen friend Bool operatnapd ;}
oBool W (X==Mo) const {return (M -i=l operator==(long X, Momen )ferator==(long X, Momen friend Boo=l operator==(long X, Momen )>erator==(long // modifie-MinCount( JulianDate operator-int +MinCount(){return int(M%M+inutesInADayDesc();
X,FatalError("increesInAa moesInAbyAa moesIn"tor // nonAallow

  3 Responses to “Category : C++ Source Code
Archive   : WLIB.ZIP
Filename : WTIME.H

  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/