Merge branch 'development' into master_joker
[openttd-joker.git] / src / date_func.h
bloba597c9c5bb5b3424d7aef3f434479837bbf417b7
1 /* $Id: date_func.h 22411 2011-05-02 17:42:12Z rubidium $ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file date_func.h Functions related to dates. */
12 #ifndef DATE_FUNC_H
13 #define DATE_FUNC_H
15 #include "date_type.h"
17 extern Year _cur_year;
18 extern Month _cur_month;
19 extern YearMonthDay _cur_date_ymd;
20 extern Date _date;
21 extern DateFract _date_fract;
22 extern uint16 _tick_counter;
24 void SetDate(Date date, DateFract fract);
25 void ConvertDateToYMD(Date date, YearMonthDay *ymd);
26 Date ConvertYMDToDate(Year year, Month month, Day day);
27 Ticks GetCurrentTickCount();
29 /**
30 * Checks whether the given year is a leap year or not.
31 * @param yr The year to check.
32 * @return True if \c yr is a leap year, otherwise false.
34 static inline bool IsLeapYear(Year yr)
36 return yr % 4 == 0 && (yr % 100 != 0 || yr % 400 == 0);
39 #endif /* DATE_FUNC_H */