Fraxinus  2023.01.05-dev+develop.0da12
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
QString timestampMilliSecondsFormat()
Definition: cxTime.cpp:22
QString timestampSecondsFormatNice()
Definition: cxTime.cpp:26
double getMilliSecondsSinceEpoch()
Definition: cxTime.cpp:44
QString timestampSecondsFormat()
Definition: cxTime.cpp:18
double getMicroSecondsSinceEpoch()
Definition: cxTime.cpp:35
QString toMillisecondsFormatNice(double secondsSinceEpoch)
Definition: cxTime.cpp:57
QString timestampMilliSecondsFormatNice()
Definition: cxTime.cpp:30
Namespace for all CustusX production code.