Elin Decompiled Documentation EA 23.239 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 => month.ToString() ?? "";
148
149 public string NameMonthShort => month.ToString() ?? "";
150
151 public string NameTime => periodOfDay.ToString().lang();
152
153 public bool IsSpring
154 {
155 get
156 {
157 if (month >= 3)
158 {
159 return month <= 5;
160 }
161 return false;
162 }
163 }
164
165 public bool IsSummer
166 {
167 get
168 {
169 if (month >= 6)
170 {
171 return month <= 8;
172 }
173 return false;
174 }
175 }
176
177 public bool IsAutumn
178 {
179 get
180 {
181 if (month >= 9)
182 {
183 return month <= 11;
184 }
185 return false;
186 }
187 }
188
189 public bool IsWinter
190 {
191 get
192 {
193 if (month < 12)
194 {
195 return month <= 2;
196 }
197 return true;
198 }
199 }
200
201 public Date Copy()
202 {
203 return new Date
204 {
205 year = year,
206 month = month,
207 day = day,
208 hour = hour,
209 min = min,
210 sec = sec
211 };
212 }
213
214 public override string ToString()
215 {
216 return GetText(TextFormat.Log);
217 }
218
219 public void AddHour(int a)
220 {
221 hour += a;
222 while (hour >= 24)
223 {
224 hour -= 24;
225 AddDay(1);
226 }
227 }
228
229 public void AddDay(int a)
230 {
231 day += a;
232 while (day > 30)
233 {
234 day -= 30;
235 AddMonth(1);
236 }
237 }
238
239 public void AddMonth(int a)
240 {
241 month += a;
242 while (month > 12)
243 {
244 month -= 12;
245 year++;
246 }
247 }
248
249 public string GetText(TextFormat format)
250 {
251 switch (format)
252 {
253 case TextFormat.LogPlusYear:
254 return year + ", " + month + "/" + day + " " + ((hour < 10) ? "0" : "") + hour + ":" + ((min < 10) ? "0" : "") + min;
255 case TextFormat.Log:
256 return month + "/" + day + " " + hour + ":" + min;
257 case TextFormat.Widget:
258 return "dateYearMonthDay".lang(year.ToString() ?? "", month.ToString() ?? "", day.ToString() ?? "");
259 case TextFormat.Schedule:
260 return "dateSchedule".lang(NameMonth, day.ToString() ?? "");
261 case TextFormat.Travel:
262 {
263 string text = "_short";
264 if (format == TextFormat.Travel)
265 {
266 return "travelDate".lang(year.ToString() ?? "", month.ToString() ?? "", day.ToString() ?? "");
267 }
268 string text2 = "";
269 if (day != 0)
270 {
271 text2 = text2 + day + Lang.Get("wDay" + text);
272 }
273 if (hour != 0)
274 {
275 text2 = text2 + hour + Lang.Get("wHour" + text);
276 }
277 if (min != 0)
278 {
279 text2 = text2 + min + Lang.Get("wMin" + text);
280 }
281 return text2 + sec + Lang.Get("wSec" + text);
282 }
283 case TextFormat.YearMonthDay:
284 return "dateYearMonthDay".lang(year.ToString() ?? "", month.ToString() ?? "", day.ToString() ?? "");
285 default:
286 return "Day " + day + " " + hour + ":" + min;
287 }
288 }
289
290 public static string GetText(int raw, TextFormat format)
291 {
292 return ToDate(raw).GetText(format);
293 }
294
295 public static string GetText(int hour)
296 {
297 if (hour < 0)
298 {
299 return "dateDayVoid".lang();
300 }
301 if (hour > 24)
302 {
303 return "dateDay".lang((hour / 24).ToString() ?? "");
304 }
305 return "dateHour".lang(hour.ToString() ?? "");
306 }
307
308 public static string GetText2(int hour)
309 {
310 if (hour < 0)
311 {
312 return "-";
313 }
314 if (hour > 24)
315 {
316 return hour / 24 + "d";
317 }
318 return hour + "h";
319 }
320
321 public int GetRawReal(int offsetHours = 0)
322 {
323 return min + (hour + offsetHours) * 60 + day * 1440 + month * 46080 + year * 552960;
324 }
325
326 public int GetRaw(int offsetHours = 0)
327 {
328 return min + (hour + offsetHours) * 60 + day * 1440 + month * 43200 + year * 518400;
329 }
330
331 public int GetRawDay()
332 {
333 return day * 1440 + month * 43200 + year * 518400;
334 }
335
336 public bool IsExpired(int time)
337 {
338 return time - GetRaw() < 0;
339 }
340
341 public int GetRemainingHours(int rawDeadLine)
342 {
343 return (rawDeadLine - GetRaw()) / 60;
344 }
345
346 public int GetRemainingSecs(int rawDeadLine)
347 {
348 return rawDeadLine - GetRaw();
349 }
350
351 public int GetElapsedMins(int rawDate)
352 {
353 return GetRaw() - rawDate;
354 }
355
356 public int GetElapsedHour(int rawDate)
357 {
358 if (rawDate != 0)
359 {
360 return (GetRaw() - rawDate) / 60;
361 }
362 return 0;
363 }
364
365 public static string SecToDate(int sec)
366 {
367 return sec / 60 / 60 + "時間 " + sec / 60 % 60 + "分 " + sec % 60 + "秒";
368 }
369
370 public static string MinToDayAndHour(int min)
371 {
372 int num = min / 60;
373 int num2 = num / 24;
374 if (num == 0)
375 {
376 return min + "分";
377 }
378 if (num2 != 0)
379 {
380 return num2 + "日と" + num % 24 + "時間";
381 }
382 return num + "時間";
383 }
384
385 public static int[] GetDateArray(int raw)
386 {
387 return new int[5]
388 {
389 raw % 60,
390 raw / 60 % 24,
391 raw / 60 / 24 % 30,
392 raw / 60 / 24 / 30 % 12,
393 raw / 60 / 24 / 30 / 12
394 };
395 }
396
397 public static Date ToDate(int raw)
398 {
399 int[] dateArray = GetDateArray(raw);
400 int num = dateArray[4];
401 int num2 = dateArray[3];
402 int num3 = dateArray[2];
403 if (num2 == 0)
404 {
405 num2 = 12;
406 num--;
407 }
408 if (num3 == 0)
409 {
410 num3 = 30;
411 num2--;
412 }
413 if (num2 == 0)
414 {
415 num2 = 12;
416 num--;
417 }
418 return new Date
419 {
420 min = dateArray[0],
421 hour = dateArray[1],
422 day = num3,
423 month = num2,
424 year = num
425 };
426 }
427}
PeriodOfDay
Definition: PeriodOfDay.cs:2
Definition: Date.cs:4
void AddHour(int a)
Definition: Date.cs:219
const int HourTokenReal
Definition: Date.cs:29
static string GetText(int hour)
Definition: Date.cs:295
int GetElapsedHour(int rawDate)
Definition: Date.cs:356
const int YearToken
Definition: Date.cs:27
const int MonthTokenReal
Definition: Date.cs:33
static string GetText(int raw, TextFormat format)
Definition: Date.cs:290
Date Copy()
Definition: Date.cs:201
int min
Definition: Date.cs:86
int hour
Definition: Date.cs:74
void AddMonth(int a)
Definition: Date.cs:239
const int MonthToken
Definition: Date.cs:25
bool IsSummer
Definition: Date.cs:166
int GetRaw(int offsetHours=0)
Definition: Date.cs:326
string NameMonth
Definition: Date.cs:147
bool IsSpring
Definition: Date.cs:154
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:308
const int DayTokenReal
Definition: Date.cs:31
override string ToString()
Definition: Date.cs:214
string NameMonthShort
Definition: Date.cs:149
int month
Definition: Date.cs:50
const int ShippingHour
Definition: Date.cs:16
static Date ToDate(int raw)
Definition: Date.cs:397
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:336
bool IsNight
Definition: Date.cs:112
bool IsWinter
Definition: Date.cs:190
static string MinToDayAndHour(int min)
Definition: Date.cs:370
const int YearTokenReal
Definition: Date.cs:35
int GetRawReal(int offsetHours=0)
Definition: Date.cs:321
static int[] GetDateArray(int raw)
Definition: Date.cs:385
int GetRemainingSecs(int rawDeadLine)
Definition: Date.cs:346
static string SecToDate(int sec)
Definition: Date.cs:365
bool IsDay
Definition: Date.cs:109
void AddDay(int a)
Definition: Date.cs:229
int sec
Definition: Date.cs:98
int GetElapsedMins(int rawDate)
Definition: Date.cs:351
int GetRawDay()
Definition: Date.cs:331
PeriodOfDay periodOfDay
Definition: Date.cs:128
string GetText(TextFormat format)
Definition: Date.cs:249
int HourNight
Definition: Date.cs:125
TextFormat
Definition: Date.cs:6
string NameTime
Definition: Date.cs:151
int GetRemainingHours(int rawDeadLine)
Definition: Date.cs:341
bool IsAutumn
Definition: Date.cs:178
Definition: EClass.cs:5
Definition: Lang.cs:6
static string Get(string id)
Definition: Lang.cs:91