author | rubidium |
Thu, 27 Mar 2008 05:15:06 +0000 | |
branch | noai |
changeset 9825 | cc77111ebd85 |
child 9833 | 89a64246458f |
permissions | -rw-r--r-- |
9825
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
1 |
/* $Id$ */ |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
2 |
|
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
3 |
/** @file ai_date.cpp handles the functions of the AIDate class */ |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
4 |
|
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
5 |
#include "ai_date.hpp" |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
6 |
#include "../../date_func.h" |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
7 |
|
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
8 |
/* static */ int32 AIDate::GetCurrentDate() |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
9 |
{ |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
10 |
return ::_date; |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
11 |
} |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
12 |
|
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
13 |
/* static */ int32 AIDate::GetYear(int32 date) |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
14 |
{ |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
15 |
if (date < 0) return -1; |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
16 |
|
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
17 |
::YearMonthDay ymd; |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
18 |
::ConvertDateToYMD(date, &ymd); |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
19 |
return ymd.year; |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
20 |
} |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
21 |
|
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
22 |
/* static */ int32 AIDate::GetMonth(int32 date) |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
23 |
{ |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
24 |
if (date < 0) return -1; |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
25 |
|
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
26 |
::YearMonthDay ymd; |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
27 |
::ConvertDateToYMD(date, &ymd); |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
28 |
return ymd.month + 1; |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
29 |
} |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
30 |
|
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
31 |
/* static */ int32 AIDate::GetDayOfMonth(int32 date) |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
32 |
{ |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
33 |
if (date < 0) return -1; |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
34 |
|
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
35 |
::YearMonthDay ymd; |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
36 |
::ConvertDateToYMD(date, &ymd); |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
37 |
return ymd.day; |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
38 |
} |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
39 |
|
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
40 |
/* static */ int32 AIDate::GetDate(int32 year, int32 month, int32 day_of_month) |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
41 |
{ |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
42 |
if (month < 1 || month > 12) return -1; |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
43 |
if (day_of_month < 1 || day_of_month > 31) return -1; |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
44 |
if (year < 1 || year > MAX_YEAR) return -1; |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
45 |
|
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
46 |
return ::ConvertYMDToDate(year, month - 1, day_of_month); |
cc77111ebd85
(svn r12437) [NoAI] -Add: functions to get the current date and to determine the year/month/day from that date.
rubidium
parents:
diff
changeset
|
47 |
} |