date_type.h

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

Generated on Tue Jan 6 19:01:35 2009 for openttd by  doxygen 1.5.6