Elin Decompiled Documentation EA 23.277 Nightly Patch 1
Loading...
Searching...
No Matches
Date.cs
Go to the documentation of this file.
1using Newtonsoft.Json;
2
3public class Date : EClass
4{
5 public enum TextFormat
6 {
8 Log,
9 Widget,
11 Travel,
14 }
15
16 public const int ShippingHour = 5;
17
18 [JsonProperty]
19 public int[] raw = new int[6];
20
21 public const int HourToken = 60;
22
23 public const int DayToken = 1440;
24
25 public const int MonthToken = 43200;
26
27 public const int YearToken = 518400;
28
29 public const int HourTokenReal = 60;
30
31 public const int DayTokenReal = 1440;
32
33 public const int MonthTokenReal = 46080;
34
35 public const int YearTokenReal = 552960;
36
37 public int year
38 {
39 get
40 {
41 return raw[0];
42 }
43 set
44 {
45 raw[0] = value;
46 }
47 }
48
49 public int month
50 {
51 get
52 {
53 return raw[1];
54 }
55 set
56 {
57 raw[1] = value;
58 }
59 }
60
61 public int day
62 {
63 get
64 {
65 return raw[2];
66 }
67 set
68 {
69 raw[2] = value;
70 }
71 }
72
73 public int hour
74 {
75 get
76 {
77 return raw[3];
78 }
79 set
80 {
81 raw[3] = value;
82 }
83 }
84
85 public int min
86 {
87 get
88 {
89 return raw[4];
90 }
91 set
92 {
93 raw[4] = value;
94 }
95 }
96
97 public int sec
98 {
99 get
100 {
101 return raw[5];
102 }
103 set
104 {
105 raw[5] = value;
106 }
107 }
108
109 public bool IsDay => !IsNight;
110
111 public bool IsNight
112 {
113 get
114 {
115 if (hour < HourNight)
116 {
117 return hour <= HourMorning;
118 }
119 return true;
120 }
121 }
122
123 public int HourMorning => 5;
124
125 public int HourNight => 19;
126
128 {
129 get
130 {
131 if (hour >= 5 && hour <= 6)
132 {
133 return PeriodOfDay.Dawn;
134 }
135 if (hour >= 7 && hour <= 17)
136 {
137 return PeriodOfDay.Day;
138 }
139 if (hour >= 18 && hour <= 19)
140 {
141 return PeriodOfDay.Dusk;
142 }
143 return PeriodOfDay.Night;
144 }
145 }
146
147 public string NameMonth => Lang.GetList("name_month")[month - 1];
148
149 public string NameSeason => Lang.GetList("name_season")[(int)EClass.world.season.Current];
150
151 public string NameMonthShort => month.ToString() ?? "";
152
153 public string NameTime => periodOfDay.ToString().lang();
154
155 public bool IsSpring
156 {
157 get
158 {
159 if (month >= 3)
160 {
161 return month <= 5;
162 }
163 return false;
164 }
165 }
166
167 public bool IsSummer
168 {
169 get
170 {
171 if (month >= 6)
172 {
173 return month <= 8;
174 }
175 return false;
176 }
177 }
178
179 public bool IsAutumn
180 {
181 get
182 {
183 if (month >= 9)
184 {
185 return month <= 11;
186 }
187 return false;
188 }
189 }
190
191 public bool IsWinter
192 {
193 get
194 {
195 if (month < 12)
196 {
197 return month <= 2;
198 }
199 return true;
200 }
201 }
202
203 public Date Copy()
204 {
205 return new Date
206 {
207 year = year,
208 month = month,
209 day = day,
210 hour = hour,
211 min = min,
212 sec = sec
213 };
214 }
215
216 public override string ToString()
217 {
218 return GetText(TextFormat.Log);
219 }
220
221 public void AddHour(int a)
222 {
223 hour += a;
224 while (hour >= 24)
225 {
226 hour -= 24;
227 AddDay(1);
228 }
229 }
230
231 public void AddDay(int a)
232 {
233 day += a;
234 while (day > 30)
235 {
236 day -= 30;
237 AddMonth(1);
238 }
239 }
240
241 public void AddMonth(int a)
242 {
243 month += a;
244 while (month > 12)
245 {
246 month -= 12;
247 year++;
248 }
249 }
250
251 public string GetText(TextFormat format)
252 {
253 switch (format)
254 {
255 case TextFormat.LogPlusYear:
256 return year + ", " + month + "/" + day + " " + ((hour < 10) ? "0" : "") + hour + ":" + ((min < 10) ? "0" : "") + min;
257 case TextFormat.Log:
258 return month + "/" + day + " " + hour + ":" + min;
259 case TextFormat.Widget:
260 return "dateYearMonthDay".lang(year.ToString() ?? "", month.ToString() ?? "", day.ToString() ?? "");
261 case TextFormat.Schedule:
262 return "dateSchedule".lang(NameMonthShort, day.ToString() ?? "");
263 case TextFormat.Travel:
264 {
265 string text = "_short";
266 if (format == TextFormat.Travel)
267 {
268 return "travelDate".lang(year.ToString() ?? "", month.ToString() ?? "", day.ToString() ?? "");
269 }
270 string text2 = "";
271 if (day != 0)
272 {
273 text2 = text2 + day + Lang.Get("wDay" + text);
274 }
275 if (hour != 0)
276 {
277 text2 = text2 + hour + Lang.Get("wHour" + text);
278 }
279 if (min != 0)
280 {
281 text2 = text2 + min + Lang.Get("wMin" + text);
282 }
283 return text2 + sec + Lang.Get("wSec" + text);
284 }
285 case TextFormat.YearMonthDay:
286 return "dateYearMonthDay".lang(year.ToString() ?? "", month.ToString() ?? "", day.ToString() ?? "");
287 default:
288 return "Day " + day + " " + hour + ":" + min;
289 }
290 }
291
292 public static string GetText(int raw, TextFormat format)
293 {
294 return ToDate(raw).GetText(format);
295 }
296
297 public static string GetText(int hour)
298 {
299 if (hour < 0)
300 {
301 return "dateDayVoid".lang();
302 }
303 if (hour > 24)
304 {
305 return "dateDay".lang((hour / 24).ToString() ?? "");
306 }
307 return "dateHour".lang(hour.ToString() ?? "");
308 }
309
310 public static string GetText2(int hour)
311 {
312 if (hour < 0)
313 {
314 return "-";
315 }
316 if (hour > 24)
317 {
318 return hour / 24 + "d";
319 }
320 return hour + "h";
321 }
322
323 public int GetRawReal(int offsetHours = 0)
324 {
325 return min + (hour + offsetHours) * 60 + day * 1440 + month * 46080 + year * 552960;
326 }
327
328 public int GetRaw(int offsetHours = 0)
329 {
330 return min + (hour + offsetHours) * 60 + day * 1440 + month * 43200 + year * 518400;
331 }
332
333 public int GetRawDay()
334 {
335 return day * 1440 + month * 43200 + year * 518400;
336 }
337
338 public bool IsExpired(int time)
339 {
340 return time - GetRaw() < 0;
341 }
342
343 public int GetRemainingHours(int rawDeadLine)
344 {
345 return (rawDeadLine - GetRaw()) / 60;
346 }
347
348 public int GetRemainingSecs(int rawDeadLine)
349 {
350 return rawDeadLine - GetRaw();
351 }
352
353 public int GetElapsedMins(int rawDate)
354 {
355 return GetRaw() - rawDate;
356 }
357
358 public int GetElapsedHour(int rawDate)
359 {
360 if (rawDate != 0)
361 {
362 return (GetRaw() - rawDate) / 60;
363 }
364 return 0;
365 }
366
367 public static string SecToDate(int sec)
368 {
369 return sec / 60 / 60 + "時間 " + sec / 60 % 60 + "分 " + sec % 60 + "秒";
370 }
371
372 public static string MinToDayAndHour(int min)
373 {
374 int num = min / 60;
375 int num2 = num / 24;
376 if (num == 0)
377 {
378 return min + "分";
379 }
380 if (num2 != 0)
381 {
382 return num2 + "日と" + num % 24 + "時間";
383 }
384 return num + "時間";
385 }
386
387 public static int[] GetDateArray(int raw)
388 {
389 return new int[5]
390 {
391 raw % 60,
392 raw / 60 % 24,
393 raw / 60 / 24 % 30,
394 raw / 60 / 24 / 30 % 12,
395 raw / 60 / 24 / 30 / 12
396 };
397 }
398
399 public static Date ToDate(int raw)
400 {
401 int[] dateArray = GetDateArray(raw);
402 int num = dateArray[4];
403 int num2 = dateArray[3];
404 int num3 = dateArray[2];
405 if (num2 == 0)
406 {
407 num2 = 12;
408 num--;
409 }
410 if (num3 == 0)
411 {
412 num3 = 30;
413 num2--;
414 }
415 if (num2 == 0)
416 {
417 num2 = 12;
418 num--;
419 }
420 return new Date
421 {
422 min = dateArray[0],
423 hour = dateArray[1],
424 day = num3,
425 month = num2,
426 year = num
427 };
428 }
429}
PeriodOfDay
Definition: PeriodOfDay.cs:2
Definition: Date.cs:4
void AddHour(int a)
Definition: Date.cs:221
const int HourTokenReal
Definition: Date.cs:29
static string GetText(int hour)
Definition: Date.cs:297
int GetElapsedHour(int rawDate)
Definition: Date.cs:358
const int YearToken
Definition: Date.cs:27
const int MonthTokenReal
Definition: Date.cs:33
static string GetText(int raw, TextFormat format)
Definition: Date.cs:292
Date Copy()
Definition: Date.cs:203
int min
Definition: Date.cs:86
int hour
Definition: Date.cs:74
void AddMonth(int a)
Definition: Date.cs:241
const int MonthToken
Definition: Date.cs:25
bool IsSummer
Definition: Date.cs:168
int GetRaw(int offsetHours=0)
Definition: Date.cs:328
string NameMonth
Definition: Date.cs:147
bool IsSpring
Definition: Date.cs:156
const int DayToken
Definition: Date.cs:23
int HourMorning
Definition: Date.cs:123
const int HourToken
Definition: Date.cs:21
static string GetText2(int hour)
Definition: Date.cs:310
const int DayTokenReal
Definition: Date.cs:31
override string ToString()
Definition: Date.cs:216
string NameMonthShort
Definition: Date.cs:151
int month
Definition: Date.cs:50
const int ShippingHour
Definition: Date.cs:16
static Date ToDate(int raw)
Definition: Date.cs:399
int[] raw
Definition: Date.cs:19
int day
Definition: Date.cs:62
int year
Definition: Date.cs:38
bool IsExpired(int time)
Definition: Date.cs:338
bool IsNight
Definition: Date.cs:112
bool IsWinter
Definition: Date.cs:192
static string MinToDayAndHour(int min)
Definition: Date.cs:372
const int YearTokenReal
Definition: Date.cs:35
int GetRawReal(int offsetHours=0)
Definition: Date.cs:323
static int[] GetDateArray(int raw)
Definition: Date.cs:387
int GetRemainingSecs(int rawDeadLine)
Definition: Date.cs:348
static string SecToDate(int sec)
Definition: Date.cs:367
bool IsDay
Definition: Date.cs:109
void AddDay(int a)
Definition: Date.cs:231
int sec
Definition: Date.cs:98
int GetElapsedMins(int rawDate)
Definition: Date.cs:353
int GetRawDay()
Definition: Date.cs:333
PeriodOfDay periodOfDay
Definition: Date.cs:128
string GetText(TextFormat format)
Definition: Date.cs:251
int HourNight
Definition: Date.cs:125
TextFormat
Definition: Date.cs:6
string NameTime
Definition: Date.cs:153
string NameSeason
Definition: Date.cs:149
int GetRemainingHours(int rawDeadLine)
Definition: Date.cs:343
bool IsAutumn
Definition: Date.cs:180
Definition: EClass.cs:6
static World world
Definition: EClass.cs:41
Definition: Lang.cs:6
static string Get(string id)
Definition: Lang.cs:91
static string[] GetList(string id)
Definition: Lang.cs:114
ID Current
Definition: Season.cs:17
Season season
Definition: World.cs:9