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