X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fgettime.h;h=66efef1d71d02005b0503f6864a35f83dedc11cd;hb=8f73ec6c6c18ea5676261064399a650911333da5;hp=611906559b5059caf127553cd0f2954d8ea28fe0;hpb=979ca23f1eae1adeb8b0083dffe7203c54d87395;p=minetest.git diff --git a/src/gettime.h b/src/gettime.h index 611906559..66efef1d7 100644 --- a/src/gettime.h +++ b/src/gettime.h @@ -17,39 +17,26 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef GETTIME_HEADER -#define GETTIME_HEADER +#pragma once -#include "irrlichttypes.h" - -/* - Get a millisecond counter value. - Precision depends on implementation. - Overflows at any value above 10000000. - - Implementation of this is done in: - Normal build: main.cpp - Server build: servermain.cpp -*/ -extern u32 getTimeMs(); - -/* - Timestamp stuff -*/ - -#include +#include #include +enum TimePrecision +{ + PRECISION_SECONDS, + PRECISION_MILLI, + PRECISION_MICRO, + PRECISION_NANO +}; + inline std::string getTimestamp() { time_t t = time(NULL); // This is not really thread-safe but it won't break anything // except its own output, so just go with it. struct tm *tm = localtime(&t); - char cs[20]; - strftime(cs, 20, "%H:%M:%S", tm); + char cs[20]; // YYYY-MM-DD HH:MM:SS + '\0' + strftime(cs, 20, "%Y-%m-%d %H:%M:%S", tm); return cs; } - - -#endif