X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftime%2Futils.cpp;h=f4a5379d44fb0418414d479f800b17d9b97916fc;hb=dff78b5a8a1d947eb3391dd919abfa04a48d589c;hp=49acd7791180616be36d56f29f0af99a30a55e42;hpb=77b028405a591207380c9dee0042eef74a646b46;p=libs%2Fcore.git diff --git a/source/time/utils.cpp b/source/time/utils.cpp index 49acd77..f4a5379 100644 --- a/source/time/utils.cpp +++ b/source/time/utils.cpp @@ -1,5 +1,5 @@ /* -This file is part of libmspframework +This file is part of libmspcore Copyright © 2006 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ @@ -9,11 +9,14 @@ Distributed under the LGPL #include #include #endif +#include "datetime.h" #include "timedelta.h" #include "timestamp.h" #include "units.h" #include "utils.h" +using namespace std; + namespace Msp { namespace Time { @@ -41,15 +44,20 @@ TimeStamp now() FILETIME ft; SystemTimeToFileTime(&st, &ft); - epoch=(ft.dwLowDateTime+(int64_t)ft.dwHighDateTime<<32)/10; + epoch=(ft.dwLowDateTime+((int64_t)ft.dwHighDateTime<<32))/10; } FILETIME ft; GetSystemTimeAsFileTime(&ft); - return TimeStamp((ft.dwLowDateTime+(int64_t)ft.dwHighDateTime<<32)/10-epoch); + return TimeStamp((ft.dwLowDateTime+((int64_t)ft.dwHighDateTime<<32))/10-epoch); #endif } +string format_now(const string &fmt) +{ + return DateTime(now()).format(fmt); +} + /** Returns the CPU time used by the program so far. */ @@ -75,7 +83,7 @@ int sleep(const TimeDelta &d) d.fill_timespec(ts); return nanosleep(&ts, 0); #else - Sleep(d/msec); + Sleep((DWORD)(d/msec)); return 0; #endif }