MCPcopy Create free account
hub / github.com/XorTroll/Goldleaf / GetCurrentTime

Function GetCurrentTime

Goldleaf/source/hos/hos_Common.cpp:161–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159 }
160
161 std::string GetCurrentTime(const bool use_12h_time) {
162 const auto posix_time = time(nullptr);
163 const auto local_time = localtime(&posix_time);
164
165 char time_str[0x20] = {};
166 if(use_12h_time) {
167 auto hour = local_time->tm_hour;
168 if(hour > 12) {
169 hour -= 12;
170 }
171 else if(hour == 0) {
172 hour = 12;
173 }
174
175 const auto ampm_str = (local_time->tm_hour >= 12) ? "PM" : "AM";
176 snprintf(time_str, sizeof(time_str), "%02d:%02d:%02d %s", hour, local_time->tm_min, local_time->tm_sec, ampm_str);
177 }
178 else {
179 snprintf(time_str, sizeof(time_str), "%02d:%02d:%02d", local_time->tm_hour, local_time->tm_min, local_time->tm_sec);
180 }
181
182 return time_str;
183 }
184
185 std::string FormatHex128(const AccountUid user_id) {
186 auto ptr = reinterpret_cast<const u8*>(user_id.uid);

Callers 2

LogImplFunction · 0.85
UpdateValuesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected