]> git.tdb.fi Git - libs/core.git/blobdiff - source/time/utils.cpp
Added DateTime
[libs/core.git] / source / time / utils.cpp
index 49acd7791180616be36d56f29f0af99a30a55e42..ad0d24550338f7c22117057a2354d42f93e6c09e 100644 (file)
@@ -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 <sys/resource.h>
 #include <sys/time.h>
 #endif
+#include "datetime.h"
 #include "timedelta.h"
 #include "timestamp.h"
 #include "units.h"
 #include "utils.h"
 
+using namespace std;
+
 namespace Msp {
 namespace Time {
 
@@ -50,6 +53,11 @@ TimeStamp now()
 #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
 }