MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / split_time

Function split_time

ogsr_engine/xrGame/date_time.cpp:70–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70void split_time(u64 time, u32& years, u32& months, u32& days, u32& hours, u32& minutes, u32& seconds, u32& milliseconds)
71{
72 milliseconds = u32(time % 1000);
73 time /= 1000;
74 seconds = u32(time % 60);
75 time /= 60;
76 minutes = u32(time % 60);
77 time /= 60;
78 hours = u32(time % 24);
79 time /= 24;
80 years = u32(u64(400) * time / u64(365 * 400 + 100 - 4 + 1) + 1);
81 u64 t1, t2, t3, t4;
82 t1 = years / 400;
83 t2 = years / 100;
84 t3 = years / 4;
85 bool a1, a2, a3;
86 a1 = !(years % 400);
87 a2 = !(years % 100);
88 a3 = !(years % 4);
89 t4 = a3 && (!a2 || a1) ? 1 : 0;
90 u64 result = u64(years - 1) * u64(365) + t1 - t2 + t3;
91 time -= result;
92 ++time;
93 months = 1;
94 if (time > 31)
95 {
96 ++months;
97 time -= 31;
98 if (time > 28 + t4)
99 {
100 ++months;
101 time -= 28 + t4;
102 if (time > 31)
103 {
104 ++months;
105 time -= 31;
106 if (time > 30)
107 {
108 ++months;
109 time -= 30;
110 if (time > 31)
111 {
112 ++months;
113 time -= 31;
114 if (time > 30)
115 {
116 ++months;
117 time -= 30;
118 if (time > 31)
119 {
120 ++months;
121 time -= 31;
122 if (time > 31)
123 {
124 ++months;
125 time -= 31;
126 if (time > 30)
127 {

Callers 14

get_time_daysFunction · 0.85
get_time_hoursFunction · 0.85
get_time_minutesFunction · 0.85
generate_timeFunction · 0.85
GetGameDateTimeMethod · 0.85
GetGameTimeForShadersMethod · 0.85
SingleLineTextMethod · 0.85
StatusMethod · 0.85
getMethod · 0.85
is_nightMethod · 0.85
SetupMethod · 0.85
GetTimeAsStringMethod · 0.85

Calls 2

u64Enum · 0.85
u32Enum · 0.70

Tested by

no test coverage detected