My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
class Nuller;
class Stream;
struct FileTime;

struct Date : RelOps< Date, Moveable<Date> > {
byte day;
byte month;
int16 year;

void Serialize(Stream& s);

bool IsValid() const;
void Set(int scalar);
int Get() const;

static Date Low() { return Date(-4000, 1, 1); }
static Date High() { return Date(4000, 1, 1); }

int Compare(Date b) const;

Date& operator++() { if(day < 28) day++; else Set(Get() + 1); return *this; }
Date& operator--() { if(day > 1) day--; else Set(Get() - 1); return *this; }

Date() { year = -32768; day = month = 0; }
Date(const Nuller&) { year = -32768; day = month = 0; }
Date(int y, int m, int d) { day = d; month = m; year = y; }
};

inline unsigned GetHashValue(Date t) {
return 512 * t.year + 32 * t.month + t.day;
}

inline bool operator==(Date a, Date b) {
return a.day == b.day && a.month == b.month && a.year == b.year;
}

template<> inline bool IsNull(const Date& d) { return d.year == -32768; }

bool operator<(Date a, Date b);

int operator-(Date a, Date b);
Date operator+(Date a, int b);
Date operator+(int a, Date b);
Date operator-(Date a, int b);
Date& operator+=(Date& a, int b);
Date& operator-=(Date& a, int b);

bool IsLeapYear(int year);

int GetDaysOfMonth(int m, int y);

int DayOfWeek(Date date);
Date LastDayOfMonth(Date d);
Date FirstDayOfMonth(Date d);
Date LastDayOfYear(Date d);
Date FirstDayOfYear(Date d);
int DayOfYear(Date d);


Date AddMonths(Date date, int months);
Date AddYears(Date date, int years);

Date GetSysDate();

String DayName(int i, int lang = 0);
String DyName(int i, int lang = 0);
String MonthName(int i, int lang = 0);
String MonName(int i, int lang = 0);

void SetDateFormat(const char *fmt);
void SetDateScan(const char *scan);
void SetDateFilter(const char *seps);

const char *StrToDate(const char *fmt, Date& d, const char *s, Date def = Null);
const char *StrToDate(Date& d, const char *s, Date def);
const char *StrToDate(Date& d, const char *s);
Date ScanDate(const char *fmt, const char *s, Date def = Null);
Date ScanDate(const char *s, Date def = Null);
String Format(Date date);
int CharFilterDate(int c);

template<>
inline String AsString(const Date& date) { return Format(date); }

struct Time : Date, RelOps< Time, Moveable<Time> > {
byte hour;
byte minute;
byte second;

void Serialize(Stream& s);

static Time High() { return Time(4000, 1, 1); }
static Time Low() { return Time(-4000, 1, 1); }

void Set(int64 scalar);
int64 Get() const;

int Compare(Time b) const;

Time() { hour = minute = second = 0; }
Time(const Nuller&) { hour = minute = second = 0; }
Time(int y, int m, int d, int h = 0, int n = 0, int s = 0)
{ day = d; month = m; year = y; hour = h; minute = n; second = s; }

Time(FileTime filetime);
FileTime AsFileTime() const;
};

inline Time ToTime(const Date& d) {
return Time(d.year, d.month, d.day);
}

inline unsigned GetHashValue(Time t) {
return t.second +
32 * (t.minute + 32 * (t.hour + 16 * (t.day + 32 * (t.month + 8 * t.year))));
}

template<> inline bool IsNull(const Time& t) { return t.year == -32768; }

bool operator==(Time a, Time b);
bool operator<(Time a, Time b);

int64 operator-(Time a, Time b);
Time operator+(Time a, int64 seconds);
Time operator+(int64 seconds, Time a);
Time operator-(Time a, int64 secs);
Time& operator+=(Time& a, int64 secs);
Time& operator-=(Time& a, int64 secs);

inline Time operator+(Time a, int i) { return a + int64(i); }
inline Time operator-(Time a, int i) { return a - int64(i); }
inline Time& operator+=(Time& a, int i) { return a += int64(i); }
inline Time& operator-=(Time& a, int i) { return a -= int64(i); }

inline Time operator+(Time a, double i) { return a + int64(i); }
inline Time operator-(Time a, double i) { return a - int64(i); }
inline Time& operator+=(Time& a, double i) { return a += int64(i); }
inline Time& operator-=(Time& a, double i) { return a -= int64(i); }

Time GetSysTime();
Time GetUtcTime();

String Format(Time time, bool seconds = true);
const char *StrToTime(const char *datefmt, Time& d, const char *s);
const char *StrToTime(Time& d, const char *s);
Time ScanTime(const char *datefmt, const char *s, Time def = Null);
Time ScanTime(const char *s, Time def = Null);

template<>
inline String AsString(const Time& time) { return Format(time); }

Change log

r4583 by cxl on Feb 13, 2012   Diff
.Core: ScanTime
Go to: 
Project members, sign in to write a code review

Older revisions

r4579 by cxl on Feb 12, 2012   Diff
*UrlEncode: ',' is now encoded
r4495 by cxl on Jan 30, 2012   Diff
Core: new Value reintegrated for
conditional compilation (SVO_VALUE
flag)
r4442 by cxl on Jan 19, 2012   Diff
Core: ScanDate
All revisions of this file

File info

Size: 4586 bytes, 150 lines

File properties

svn:eol-style
native
Powered by Google Project Hosting