OpenTTD

date_func.h
Go to the documentation of this file.
1 /* $Id: date_func.h 22411 2011-05-02 17:42:12Z rubidium $ */
2
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 */
9
12 #ifndef DATE_FUNC_H
13 #define DATE_FUNC_H
14
15 #include "date_type.h"
16
17 extern Year _cur_year;
18 extern Month _cur_month;
19 extern Date _date;
20 extern DateFract _date_fract;
21 extern uint16 _tick_counter;
22
23 void SetDate(Date date, DateFract fract);
24 void ConvertDateToYMD(Date date, YearMonthDay *ymd);
25 Date ConvertYMDToDate(Year year, Month month, Day day);
26
32 static inline bool IsLeapYear(Year yr)
33 {
34 return yr % 4 == 0 && (yr % 100 != 0 || yr % 400 == 0);
35 }
36
37 #endif /* DATE_FUNC_H */
_cur_year
Year _cur_year
Current year, starting at 0.
Definition: date.cpp:26
_date_fract
DateFract _date_fract
Fractional part of the day.
Definition: date.cpp:29
Year
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
Definition: date_type.h:20
_date
Date _date
Current date in days (day counter)
Definition: date.cpp:28
_tick_counter
uint16 _tick_counter
Ever incrementing (and sometimes wrapping) tick counter for setting off various events.
Definition: date.cpp:30
YearMonthDay
Data structure to convert between Date and triplet (year, month, and day).
Definition: date_type.h:103
DateFract
uint16 DateFract
The fraction of a date we&#39;re in, i.e. the number of ticks since the last date changeover.
Definition: date_type.h:17
_cur_month
Month _cur_month
Current month (0..11)
Definition: date.cpp:27
Month
uint8 Month
Type for the month, note: 0 based, i.e. 0 = January, 11 = December.
Definition: date_type.h:21
ConvertDateToYMD
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
Definition: date.cpp:94
IsLeapYear
static bool IsLeapYear(Year yr)
Checks whether the given year is a leap year or not.
Definition: date_func.h:32
ConvertYMDToDate
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: date.cpp:149
Day
uint8 Day
Type for the day of the month, note: 1 based, first day of a month is 1.
Definition: date_type.h:22
date_type.h
Types related to the dates in OpenTTD.
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:16
SetDate
void SetDate(Date date, DateFract fract)
Set the date.
Definition: date.cpp:37