Qt Virtual Chart Table (QVCT)
CDataTimeValidity.cpp
Go to the documentation of this file.
1 // INDENTING (emacs/vi): -*- mode:c++; tab-width:2; c-basic-offset:2; intent-tabs-mode:nil; -*- ex: set tabstop=2 expandtab:
2 
3 /*
4  * Qt Virtual Chart Table (QVCT)
5  * Copyright (C) 2012 Cedric Dufour <http://cedric.dufour.name>
6  * Author: Cedric Dufour <http://cedric.dufour.name>
7  *
8  * The Qt Virtual Chart Table (QVCT) is free software:
9  * you can redistribute it and/or modify it under the terms of the GNU General
10  * Public License as published by the Free Software Foundation, Version 3.
11  *
12  * The Qt Virtual Chart Table (QVCT) is distributed in the hope
13  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  * See the GNU General Public License for more details.
17  */
18 
19 // QT
20 #include <QDateTime>
21 
22 // QVCT
23 #include "QVCTRuntime.hpp"
25 
26 
27 //------------------------------------------------------------------------------
28 // CONSTRUCTORS / DESTRUCTOR
29 //------------------------------------------------------------------------------
30 
32  : fdTimeLastTime( UNDEFINED_VALUE )
33  , fdErrorTime( UNDEFINED_VALUE )
34  , bInvalidTime( false )
35 {}
36 
37 
38 //------------------------------------------------------------------------------
39 // METHODS
40 //------------------------------------------------------------------------------
41 
42 //
43 // GETTERS
44 //
45 
47 {
48  if( bInvalidTime ) return false;
49  if( fdErrorTime != UNDEFINED_VALUE && fdErrorTime > QVCTRuntime::useSettings()->getMaxErrorTime() ) return false;
50  if( fdTimeLastTime != UNDEFINED_VALUE && microtime() - fdTimeLastTime > QVCTRuntime::useSettings()->getMaxAgeTime() ) return false;
51  return true;
52 }
53 
double fdErrorTime
Time error, in seconds.
bool isValidTime() const
Returns the time's (global) validity status.
double fdTimeLastTime
Time last-set time, in seconds from Unix epoch.
bool bInvalidTime
Time (forced) invalidity status.
static constexpr double UNDEFINED_VALUE
static CSettings * useSettings()
double microtime()
Returns the system time with microseconds resolution, in seconds.
Definition: main.cpp:30