MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / getCurrentTimeMilliseconds

Method getCurrentTimeMilliseconds

Libraries/Http/HttpAsyncFileServer.cpp:793–807  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

791}
792
793int64_t HttpAsyncFileServer::Internal::getCurrentTimeMilliseconds()
794{
795#if SC_PLATFORM_WINDOWS
796 struct _timeb t;
797 _ftime_s(&t);
798 return static_cast<int64_t>(t.time) * 1000 + t.millitm;
799#else
800 struct timespec nowTimeSpec;
801 clock_gettime(CLOCK_REALTIME, &nowTimeSpec);
802 constexpr int64_t nanosecondsToMilliseconds = 1000 * 1000;
803 constexpr int64_t roundingNanoseconds = nanosecondsToMilliseconds / 2;
804 return static_cast<int64_t>(nowTimeSpec.tv_sec) * 1000 +
805 (static_cast<int64_t>(nowTimeSpec.tv_nsec) + roundingNanoseconds) / nanosecondsToMilliseconds;
806#endif
807}
808
809Result HttpAsyncFileServer::Internal::formatHttpDate(int64_t millisecondsSinceEpoch, char* buffer, size_t bufferSize,
810 size_t& outLength)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected