updated documentation

This commit is contained in:
2022-09-21 22:53:41 +08:00
parent 34a9fe105c
commit ce2dd054e3
14 changed files with 45 additions and 110 deletions
-79
View File
@@ -1,79 +0,0 @@
#include <sys/types.h>
#include <time.h>
#include <iostream>
#include "cal.H"
using namespace std;
Calendar::Calendar(void)
{
time_t clk = time(0);
struct tm *now = localtime(&clk);
_currdate = asJulianNumber(now->tm_mon+1, now->tm_mday, now->tm_year+1900);
}
Calendar::~Calendar()
{}
// year_ in yyyy format
unsigned int Calendar::asJulianNumber(int month_,int day_,int year_)
{
unsigned long c,ya;
if (month_>2) month_-=3;
else { month_+=9; year_--; }
c=year_/100;
ya=year_-100*c;
return ((146097*c)>>2)+((1461*ya)>>2)+(153*month_+2)/5+day_+1721119;
}
void Calendar::split(int& month_,int& day_,int& year_)
{
unsigned long d;
unsigned long j=_currdate-1721119;
year_=(int) (((j<<2)-1)/146097);
j=(j<<2)-1-146097*year_;
d=(j>>2);
j=((d<<2)+3)/1461;
d=(d<<2)+3-1461*j;
d=(d+4)>>2;
month_=(int)(5*d-3)/153;
d=5*d-3-153*month_;
day_=(int)((d+5)/5);
year_=(int)(100*year_+j);
if (month_<10) month_+=3;
else { month_-=9; year_++; }
}
int Calendar::dayInWeek(void)
{
return ((((_currdate+1)%7)+6)%7)+1;
}
Calendar &Calendar::nextWeekday(void)
{
(*this) += 1;
while (!isWeekday()) (*this)+= 1;
return *this;
}
int Calendar::isWeekday(void)
{
return (dayInWeek()<6)?1:0;
}
Calendar &Calendar::operator+= (int incr_)
{
_currdate += incr_;
return *this;
}
ostream &operator<< (ostream &os_, Calendar &that_)
{
int mo, day, year;
that_.split(mo,day,year);
os_ << year << "-" << mo << "-" << day;
// the below is a pain for monetdb
//os_ << mo << "/" << day << "/" << year;
return os_;
}
+5 -2
View File
@@ -2,7 +2,8 @@
#include <time.h>
#include <iostream>
#include "cal.H"
#include "cal.hpp"
using namespace std;
Calendar::Calendar(void)
{
@@ -71,6 +72,8 @@ ostream &operator<< (ostream &os_, Calendar &that_)
{
int mo, day, year;
that_.split(mo,day,year);
os_ << mo << "/" << day << "/" << year;
os_ << year << "-" << mo << "-" << day;
// the below is a pain for monetdb
//os_ << mo << "/" << day << "/" << year;
return os_;
}
@@ -4,7 +4,7 @@
#define genIMPLEMENTATION
#include <iostream.h>
#include "RandGen.H"
#include "RandGen.hpp"
int num[6];
int nelems=0;
@@ -10,8 +10,8 @@
#include <fstream>
#include <sys/time.h>
#include "RandGen.H"
#include "cal.H"
#include "RandGen.hpp"
#include "cal.hpp"
using namespace std;
inline int max(int a, int b)
{
+5 -5
View File
@@ -5,16 +5,16 @@ all: histgen tickgen
clean:
rm -rf *.o histgen tickgen
%.o: %.C
g++-12 -Ofast -march=native -g -c $<
%.o: %.cpp
$(CXX) -Ofast -march=native -g -c $<
tickgen: cal.o Time.o tickgen.o
g++-12 -lstdc++ -Ofast -march=native -flto -o tickgen cal.o Time.o tickgen.o
$(CXX) -lstdc++ -Ofast -march=native -flto -o tickgen cal.o Time.o tickgen.o
histgen: cal.o histgen.o
g++-12 -lstdc++ -Ofast -flto -march=native -o histgen cal.o histgen.o
$(CXX) -lstdc++ -Ofast -flto -march=native -o histgen cal.o histgen.o
timetest: Time.o timetest.o
g++-12 -lstdc++ -g -o timetest Time.o timetest.o
$(CXX) -lstdc++ -g -o timetest Time.o timetest.o
@@ -10,9 +10,9 @@
#include <fstream>
#include <sys/time.h>
#include "RandGen.H"
#include "cal.H"
#include "Time.H"
#include "RandGen.hpp"
#include "cal.hpp"
#include "Time.hpp"
using namespace std;