date_type.h

Go to the documentation of this file.
00001 /* $Id: date_type.h 15077 2009-01-13 22:58:03Z smatz $ */
00002 
00005 #ifndef DATE_TYPE_H
00006 #define DATE_TYPE_H
00007 
00014 enum {
00015   DAY_TICKS = 74,          
00016   DAYS_IN_YEAR = 365,      
00017   DAYS_IN_LEAP_YEAR = 366, 
00018 };
00019 
00020 /*
00021  * ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR and DAYS_TILL_ORIGINAL_BASE_YEAR are
00022  * primarily used for loading newgrf and savegame data and returning some
00023  * newgrf (callback) functions that were in the original (TTD) inherited
00024  * format, where '_date == 0' meant that it was 1920-01-01.
00025  */
00026 
00028 #define ORIGINAL_BASE_YEAR 1920
00029 
00030 #define ORIGINAL_END_YEAR 2051
00031 
00032 #define ORIGINAL_MAX_YEAR 2090
00033 
00038 #define DAYS_TILL_ORIGINAL_BASE_YEAR (DAYS_IN_YEAR * ORIGINAL_BASE_YEAR + ORIGINAL_BASE_YEAR / 4 - ORIGINAL_BASE_YEAR / 100 + ORIGINAL_BASE_YEAR / 400)
00039 
00040 /* The absolute minimum & maximum years in OTTD */
00041 #define MIN_YEAR 0
00042 /* MAX_YEAR, nicely rounded value of the number of years that can
00043  * be encoded in a single 32 bits date, about 2^31 / 366 years. */
00044 #define MAX_YEAR 5000000
00045 
00046 typedef int32  Date;
00047 typedef uint16 DateFract;
00048 
00049 typedef int32  Year;
00050 typedef uint8  Month;
00051 typedef uint8  Day;
00052 
00057 struct YearMonthDay {
00058   Year  year;   
00059   Month month;  
00060   Day   day;    
00061 };
00062 
00063 static const Year INVALID_YEAR = -1;
00064 static const Date INVALID_DATE = -1;
00065 
00066 #endif /* DATE_TYPE_H */

Generated on Fri Jul 31 22:33:14 2009 for OpenTTD by  doxygen 1.5.6