MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / TryGetTm

Function TryGetTm

Sources/Shared/Containers/DateTime.cpp:175–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173 }
174
175 static const tm* TryGetTm(time_t t, DateTime::TimeZone tz, struct tm* temp) noexcept
176 {
177 if (tz.IsLocal()) {
178 return Implementation::GetLocalTm(&t, temp);
179 }
180
181 t += (time_t)tz.GetOffset();
182#if !defined(__VMS__) // Time is unsigned so avoid warning
183 if (t < 0) {
184 return nullptr;
185 }
186#endif
187
188#if defined(DEATH_TARGET_WINDOWS)
189 return (gmtime_s(temp, &t) == 0 ? temp : nullptr);
190#else
191 // TODO: This function is not thread-safe on Unix - use gmtime_r instead
192 const tm* const result = gmtime(&t);
193 if (result == nullptr) {
194 return nullptr;
195 }
196
197 std::memcpy(temp, result, sizeof(struct tm));
198 return temp;
199#endif
200 }
201
202 template<class T>
203 static bool GetNumericToken(const T* string, std::size_t length, std::size_t& i, std::size_t width, std::int32_t* number, std::size_t* scannedDigitsCount = nullptr) noexcept

Callers 1

PartitionedMethod · 0.85

Calls 3

GetLocalTmFunction · 0.85
IsLocalMethod · 0.80
GetOffsetMethod · 0.45

Tested by

no test coverage detected