equal
deleted
inserted
replaced
4 #include "openttd.h" |
4 #include "openttd.h" |
5 #include "date.h" |
5 #include "date.h" |
6 #include "variables.h" |
6 #include "variables.h" |
7 #include "macros.h" |
7 #include "macros.h" |
8 #include "vehicle.h" |
8 #include "vehicle.h" |
9 #include "network.h" |
9 #include "network/network.h" |
10 #include "network_data.h" |
10 #include "network/network_data.h" |
11 #include "network_server.h" |
11 #include "network/network_server.h" |
12 #include "functions.h" |
12 #include "functions.h" |
13 #include "currency.h" |
13 #include "currency.h" |
14 |
14 |
15 Year _cur_year; |
15 Year _cur_year; |
16 Month _cur_month; |
16 Month _cur_month; |
90 /* There are 97 leap years in 400 years */ |
90 /* There are 97 leap years in 400 years */ |
91 Year yr = 400 * (date / (365 * 400 + 97)); |
91 Year yr = 400 * (date / (365 * 400 + 97)); |
92 int rem = date % (365 * 400 + 97); |
92 int rem = date % (365 * 400 + 97); |
93 uint16 x; |
93 uint16 x; |
94 |
94 |
95 /* There are 24 leap years in 100 years */ |
95 if (rem >= 365 * 100 + 25) { |
96 yr += 100 * (rem / (365 * 100 + 24)); |
96 /* There are 25 leap years in the first 100 years after |
97 rem = rem % (365 * 100 + 24); |
97 * every 400th year, as every 400th year is a leap year */ |
|
98 yr += 100; |
|
99 rem -= 365 * 100 + 25; |
|
100 |
|
101 /* There are 24 leap years in the next couple of 100 years */ |
|
102 yr += 100 * (rem / (365 * 100 + 24)); |
|
103 rem = (rem % (365 * 100 + 24)); |
|
104 } |
|
105 |
|
106 if (!IsLeapYear(yr) && rem >= 365 * 4) { |
|
107 /* The first 4 year of the century are not always a leap year */ |
|
108 yr += 4; |
|
109 rem -= 365 * 4; |
|
110 } |
98 |
111 |
99 /* There is 1 leap year every 4 years */ |
112 /* There is 1 leap year every 4 years */ |
100 yr += 4 * (rem / (365 * 4 + 1)); |
113 yr += 4 * (rem / (365 * 4 + 1)); |
101 rem = rem % (365 * 4 + 1); |
114 rem = rem % (365 * 4 + 1); |
102 |
115 |