diff options
author | zuu <zuu@openttd.org> | 2014-02-06 19:50:34 +0000 |
---|---|---|
committer | zuu <zuu@openttd.org> | 2014-02-06 19:50:34 +0000 |
commit | 96030141026ded3f892510ff9e3643319f27ebd8 (patch) | |
tree | e6e7475076685c561a7d1ff9e1161dbdc56d5f8b /src/script/api/script_date.cpp | |
parent | 1dbd59e6ab9a917214d98c53a8ab8ca5b0d47223 (diff) | |
download | openttd-96030141026ded3f892510ff9e3643319f27ebd8.tar.xz |
(svn r26307) -Add: [nogo] Allow GS to hide story page date
Diffstat (limited to 'src/script/api/script_date.cpp')
-rw-r--r-- | src/script/api/script_date.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/script/api/script_date.cpp b/src/script/api/script_date.cpp index 1f80b40d7..6ff92deba 100644 --- a/src/script/api/script_date.cpp +++ b/src/script/api/script_date.cpp @@ -14,45 +14,50 @@ #include "script_date.hpp" #include "../../date_func.h" -/* static */ int32 ScriptDate::GetCurrentDate() +/* static */ bool ScriptDate::IsValidDate(Date date) { - return ::_date; + return date >= 0; } -/* static */ int32 ScriptDate::GetYear(int32 date) +/* static */ ScriptDate::Date ScriptDate::GetCurrentDate() { - if (date < 0) return -1; + return (ScriptDate::Date)_date; +} + +/* static */ int32 ScriptDate::GetYear(ScriptDate::Date date) +{ + if (date < 0) return DATE_INVALID; ::YearMonthDay ymd; ::ConvertDateToYMD(date, &ymd); return ymd.year; } -/* static */ int32 ScriptDate::GetMonth(int32 date) +/* static */ int32 ScriptDate::GetMonth(ScriptDate::Date date) { - if (date < 0) return -1; + if (date < 0) return DATE_INVALID; ::YearMonthDay ymd; ::ConvertDateToYMD(date, &ymd); return ymd.month + 1; } -/* static */ int32 ScriptDate::GetDayOfMonth(int32 date) +/* static */ int32 ScriptDate::GetDayOfMonth(ScriptDate::Date date) { - if (date < 0) return -1; + if (date < 0) return DATE_INVALID; ::YearMonthDay ymd; ::ConvertDateToYMD(date, &ymd); return ymd.day; } -/* static */ int32 ScriptDate::GetDate(int32 year, int32 month, int32 day_of_month) +/* static */ ScriptDate::Date ScriptDate::GetDate(int32 year, int32 month, int32 day_of_month) { - if (month < 1 || month > 12) return -1; - if (day_of_month < 1 || day_of_month > 31) return -1; - if (year < 0 || year > MAX_YEAR) return -1; + if (month < 1 || month > 12) return DATE_INVALID; + if (day_of_month < 1 || day_of_month > 31) return DATE_INVALID; + if (year < 0 || year > MAX_YEAR) return DATE_INVALID; - return ::ConvertYMDToDate(year, month - 1, day_of_month); + return (ScriptDate::Date)::ConvertYMDToDate(year, month - 1, day_of_month); } /* static */ int32 ScriptDate::GetSystemTime() |