-
Notifications
You must be signed in to change notification settings - Fork 8
/
time.rules
63 lines (51 loc) · 3.68 KB
/
time.rules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
time_adjust_leap_seconds_since_1972_count = 26
time_since_epoch_days = floor(vector(time() / (86400 * 365)))
time_current_year = 1970 + round(vector(time()/ (86400 * 365.242196) -0.5))
time_start_current_year_seconds = (floor(vector(time() / (86400) / 365)) * 86400 * 365) + (floor(vector(((time()) + (86400 * 365))/ (86400) / (365 * 4))) * 86400)
# The above rule is accurate up to 2099, the following rule will make this accurate to 2399
# (floor(vector(time() / (86400) / 365)) * 86400 * 365) + (floor(vector(((time()) + (86400 * 365))/ (86400) / (365 * 4))) * 86400) - (floor(vector(((time()) - (86400 * 365 * 69))/ (86400) / (365.25 * 100))) * 86400)
time_end_of_current_day_seconds = floor(vector(time() / 86400) +1) * 86400
time_current_day_remaining_seconds = time_end_of_current_day_seconds - time()
time_is_leap_year_bool = (time_current_year % 4 == bool 0 ) and ((time_current_year % 400 == bool 0 ) or (time_current_year % 100 != bool 0 ))
time_end_current_year_seconds = time_start_current_year_seconds + (365 * 86400) + (time_is_leap_year_bool * 86400)
time_end_of_current_jan_seconds = time_start_current_year_seconds + (31 * 86400)
time_end_of_current_feb_seconds = time_end_of_current_jan_seconds + (28 * 86400) + (time_is_leap_year_bool * 86400)
time_end_of_current_mar_seconds = time_end_of_current_feb_seconds + (31 * 86400)
time_end_of_current_apr_seconds = time_end_of_current_mar_seconds + (30 * 86400)
time_end_of_current_may_seconds = time_end_of_current_apr_seconds + (31 * 86400)
time_end_of_current_jun_seconds = time_end_of_current_may_seconds + (31 * 86400)
time_end_of_current_jul_seconds = time_end_of_current_jun_seconds + (30 * 86400)
time_end_of_current_aug_seconds = time_end_of_current_jul_seconds + (31 * 86400)
time_end_of_current_sep_seconds = time_end_of_current_aug_seconds + (30 * 86400)
time_end_of_current_oct_seconds = time_end_of_current_sep_seconds + (31 * 86400)
time_end_of_current_nov_seconds = time_end_of_current_oct_seconds + (30 * 86400)
time_end_of_current_dec_seconds = time_end_of_current_nov_seconds + (31 * 86400)
time_current_month = (
1 +
(time() > bool time_end_of_current_jan_seconds) +
(time() > bool time_end_of_current_feb_seconds) +
(time() > bool time_end_of_current_mar_seconds) +
(time() > bool time_end_of_current_apr_seconds) +
(time() > bool time_end_of_current_may_seconds) +
(time() > bool time_end_of_current_jun_seconds) +
(time() > bool time_end_of_current_jul_seconds) +
(time() > bool time_end_of_current_aug_seconds) +
(time() > bool time_end_of_current_sep_seconds) +
(time() > bool time_end_of_current_oct_seconds) +
(time() > bool time_end_of_current_nov_seconds))
time_end_of_current_month_seconds = (
((time_current_month == bool 1) * time_end_of_current_jan_seconds) +
((time_current_month == bool 2) * time_end_of_current_feb_seconds) +
((time_current_month == bool 3) * time_end_of_current_mar_seconds) +
((time_current_month == bool 4) * time_end_of_current_apr_seconds) +
((time_current_month == bool 5) * time_end_of_current_may_seconds) +
((time_current_month == bool 6) * time_end_of_current_jun_seconds) +
((time_current_month == bool 7) * time_end_of_current_jul_seconds) +
((time_current_month == bool 8) * time_end_of_current_aug_seconds) +
((time_current_month == bool 9) * time_end_of_current_sep_seconds) +
((time_current_month == bool 10) * time_end_of_current_oct_seconds) +
((time_current_month == bool 11) * time_end_of_current_nov_seconds) +
((time_current_month == bool 12) * time_end_of_current_dec_seconds))
time_current_month_remaining_seconds = time_end_of_current_month_seconds - time()
time_current_weekday = 1 + (((time() / 86400) -4) % 7)
time_is_weekday_bool = time_current_day < bool 5