summaryrefslogtreecommitdiff
path: root/date.h
blob: 96fa2799ab021fd753658fadefaeada1bfe35305 (plain)
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
/* $Id$ */

/**
 * 1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885. On
 *                    an overflow the new day begun and 65535 / 885 = 74.
 * 1 tick is approximately 30 ms.
 * 1 day is thus about 2 seconds (74 * 30 = 2220) on a machine that can run OpenTTD normally
 */
#define DAY_TICKS 74

#define MAX_YEAR_BEGIN_REAL 1920
#define MAX_YEAR_END_REAL 2090
#define MAX_YEAR_END 170

/* Year and Date are defined elsewhere */
typedef uint8  Month;
typedef uint8  Day;
typedef uint16 DateFract;

typedef struct YearMonthDay {
	Year  year;
	Month month;
	Day   day;
} YearMonthDay;

extern Year      _cur_year;
extern Month     _cur_month;
extern Date      _date;
extern DateFract _date_fract;


void SetDate(Date date);
void ConvertDayToYMD(YearMonthDay *ymd, Date date);
uint ConvertYMDToDay(Year year, Month month, Day day);
Date ConvertIntDate(uint date);