-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfbDate.h
More file actions
81 lines (61 loc) · 2.89 KB
/
fbDate.h
File metadata and controls
81 lines (61 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* $Id: fbDate.h,v 1.6 2008/03/29 16:25:35 wyverex Exp $ */
#ifndef fbDATE_H
#define fbDATE_H
#include <ctime>
#include "global.h"
/**
* fbDate
* Julian Date Object, used to track backup schedules
* @author Byron Heads
* @date March 15, 2008
*/
class fbDate
{
public:
fbDate(void); /// < seeds with localtime
fbDate(fbDate& date); /// < copies julian
fbDate(tm& time); /// < convert from tm structure
fbDate(const int _month, const int _day, const int _year); /// < manual input
fbDate(unsigned long _julian); /// < julian values... from file anyone?
~fbDate(void); /// < clean up.. not sure we have anything here yet?
unsigned long getJulian() const {return julian;}; /// < get the julian value, for saving?
void setJulian(const unsigned long _julian) {julian = _julian; update();}; /// < set from julian
void setJulian(const int _month, const int _day, const int _year); /// < set from manule date
void setJulian(tm& time){setJulian(time.tm_mon, time.tm_mday, time.tm_year);}; /// < set from tm struct
void setJulianLocal(); /// < sets to local date
int getMonth() const; /// < get the month value
int getDay() const; /// < get the day value
int getYear() const; /// < get the year value
fbDate& operator=(const fbDate& right); /// < assignment operator
/// add day to julian
fbDate& operator+(const int right){julian+= right; update();return *this;};
fbDate& operator+=(const int right){julian+= right; update();return *this;};
fbDate& operator++(){++julian; update();return *this;};
fbDate& operator++(const int right){++julian; update();return *this;};
//subtract day from julian
fbDate& operator-(const int right){julian-= right; update();return *this;};
fbDate& operator-=(const int right){julian-= right; update();return *this;};
fbDate& operator--(){--julian; update();return *this;};
fbDate& operator--(const int right){--julian; update();return *this;};
void addDay(const int num = 1){*this += num;}; /// < add a day or more
void addWeek(const int num = 1){*this += 7 * num;}; /// < add a week or more
void addMonth(const int num = 1); /// < add a month or more
//compare julian dates
bool operator==(const fbDate& right) {return julian == right.julian;};
bool operator>=(const fbDate& right) {return julian >= right.julian;};
bool operator<=(const fbDate& right) {return julian <= right.julian;};
bool operator>(const fbDate& right) {return julian > right.julian;};
bool operator<(const fbDate& right) {return julian < right.julian;};
//output --- !!!!! needs to be added!
void mdy(string& d);
void my(string& d);
private:
unsigned long julian; /// < the julian day
int year; /// < the date year
int mon; /// < the date month
int day; /// < the date's day
void update(); /// < call update when the julian changes to update year, mon, day
/// its a long calculation, so don't call to often
void ltostr(long val, string& str);
};
#endif