NorMIT-nav  22.09
An IGT application
cxTime.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 #include "cxTime.h"
12 #include <QDateTime>
13 #include <boost/cstdint.hpp>
14 
15 namespace cx
16 {
17 
19 {
20  return QString("yyyyMMdd'T'hhmmss");
21 }
23 {
24  return QString("yyyyMMdd'T'hhmmsszzz");
25 }
27 {
28  return QString("yyyy-MM-dd hh:mm:ss");
29 }
31 {
32  return QString("yyyy-MM-dd hh:mm:ss.zzz");
33 }
34 
36 {
37 #if QT_VERSION >= 0x040700
38  return QDateTime::currentDateTime().toMSecsSinceEpoch()*1000; //microseconds
39 #else
40  return getMilliSecondsSinceEpoch()*1000;
41 #endif
42 }
43 
45 {
46 #if QT_VERSION >= 0x040700
47  return QDateTime::currentDateTime().toMSecsSinceEpoch(); //milliseconds
48 #else
49  QDateTime now = QDateTime::currentDateTime();
50  boost::uint64_t now_t64 = now.toTime_t();
51  now_t64 *= 1000;
52  now_t64 += now.time().msec();
53  return now_t64;
54 #endif
55 }
56 
57 QString toMillisecondsFormatNice(double secondsSinceEpoch)
58 {
59  QDateTime time;
60  time.setMSecsSinceEpoch(secondsSinceEpoch);
61  return time.toString(timestampMilliSecondsFormatNice());
62 }
63 
64 } // namespace cx
cx::timestampMilliSecondsFormat
QString timestampMilliSecondsFormat()
Definition: cxTime.cpp:22
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::getMilliSecondsSinceEpoch
double getMilliSecondsSinceEpoch()
Definition: cxTime.cpp:44
cx::getMicroSecondsSinceEpoch
double getMicroSecondsSinceEpoch()
Definition: cxTime.cpp:35
cx::timestampSecondsFormatNice
QString timestampSecondsFormatNice()
Definition: cxTime.cpp:26
cx::timestampSecondsFormat
QString timestampSecondsFormat()
Definition: cxTime.cpp:18
cx::toMillisecondsFormatNice
QString toMillisecondsFormatNice(double secondsSinceEpoch)
Definition: cxTime.cpp:57
cx::timestampMilliSecondsFormatNice
QString timestampMilliSecondsFormatNice()
Definition: cxTime.cpp:30
cxTime.h