73 QDateTime __qDateTime = QDateTime::fromTime_t( _fdValue );
74 __qDateTime = __qDateTime.addMSecs( 1000.0*fmod( _fdValue, 1.0 ) + 0.5 );
75 QTime __qTime = _eUnitTimeZone ==
CUnitTimeZone::UTC ? __qDateTime.toUTC().time() : __qDateTime.toLocalTime().time();
76 return 3600.0*__qTime.hour() + 60.0*__qTime.minute() + __qTime.second() + __qTime.msec()/1000.0;
81 QDateTime __qDateTime = QDateTime::fromTime_t( _fdValue );
82 __qDateTime = __qDateTime.addMSecs( 1000.0*fmod( _fdValue, 1.0 ) + 0.5 );
83 QTime __qTime = _eUnitTimeZone ==
CUnitTimeZone::UTC ? __qDateTime.toUTC().time() : __qDateTime.toLocalTime().time();
89 int __iHour = __qTime.hour();
90 int __iMin = __qTime.minute();
91 double __fdSec = __qTime.second() + (double)__qTime.msec()/1000.0;
92 QString __qsSec = QString::number( __fdSec,
'f', _iPrecision ).prepend(
"0" ).right( 2+( _iPrecision>0 ? _iPrecision+1 : 0 ) );
93 if( __qsSec[0] ==
'1' ) { __iMin += 1; __qsSec[0] =
'0'; }
94 QString __qsMin = QString::number( __iMin ).prepend(
"0" ).right( 2 );
95 if( __qsMin[0] ==
'6' ) { __iHour += 1; __qsMin[0] =
'0'; }
96 QString __qsHour = QString::number( __iHour );
97 return __qsHour+
":"+__qsMin+
":"+__qsSec+( _eUnitTimeZone ==
CUnitTimeZone::UTC ?
"Z" :
"" );
102 int __iHour = __qTime.hour();
103 double __fdMin = __qTime.minute() + ( (double)__qTime.second() + (double)__qTime.msec()/1000.0 )/60.0;
104 QString __qsMin = QString::number( __fdMin,
'f', _iPrecision ).prepend(
"0" ).right( 2+( _iPrecision>0 ? _iPrecision+1 : 0 ) );
105 if( __qsMin[0] ==
'6' ) { __iHour += 1; __qsMin[0] =
'0'; }
106 QString __qsHour = QString::number( __iHour );
124 static const QRegExp __qRegExpHMS(
"^\\s*(0?\\d|1\\d|2[0-3]):(0?\\d|[1-5]\\d):(0?\\d|[1-5]\\d)(\\.\\d+)?\\s*([ZzLl])?\\s*$" );
125 static const QRegExp __qRegExpHM(
"^\\s*(0?\\d|1\\d|2[0-3]):((0?\\d|[1-5]\\d)(\\.\\d+)?)\\s*(ZzLl)?\\s*$" );
127 if( _pbOK ) *_pbOK =
false;
129 QDateTime __qDateTime;
130 __qDateTime.setTime_t( _fdDate );
131 if( __qRegExpHMS.exactMatch( _rqString ) )
134 QString __qsTimeZone = __qRegExpHMS.cap(5).toUpper();
137 __qDateTime.setTimeSpec( __eUnitTimeZone ==
CUnitTimeZone::UTC ? Qt::UTC : Qt::LocalTime );
138 int __iHour = __qRegExpHMS.cap(1).toInt( &__bOK );
139 if( !__bOK )
return 0.0;
140 int __iMin = __qRegExpHMS.cap(2).toInt( &__bOK );
141 if( !__bOK )
return 0.0;
142 int __iSec = __qRegExpHMS.cap(3).toInt( &__bOK );
143 if( !__bOK )
return 0.0;
145 if( !__qRegExpHMS.cap(4).isEmpty() )
147 __iMilli = 1000*__qRegExpHMS.cap(4).toDouble( &__bOK );
148 if( !__bOK )
return 0.0;
150 __qDateTime.setTime( QTime( __iHour, __iMin, __iSec, __iMilli ) );
152 else if( __qRegExpHM.exactMatch( _rqString ) )
155 QString __qsTimeZone = __qRegExpHM.cap(5).toUpper();
158 __qDateTime.setTimeSpec( __eUnitTimeZone ==
CUnitTimeZone::UTC ? Qt::UTC : Qt::LocalTime );
159 int __iHour = __qRegExpHM.cap(1).toInt( &__bOK );
160 if( !__bOK )
return 0.0;
161 double __fdMin = __qRegExpHM.cap(2).toDouble( &__bOK );
162 if( !__bOK )
return 0.0;
163 double __fdSec = modf( __fdMin, &__fdMin ) * 60.0;
164 int __iMin = (int)__fdMin;
165 int __iMilli = (int)( modf( __fdSec, &__fdSec )*1000.0 );
166 int __iSec = (int)__fdSec;
167 if( __iMilli >= 1000 ) { __iMilli -= 1000; __iSec += 1; }
168 if( __iSec >= 60 ) { __iSec -= 60; __iMin += 1; }
169 if( __iMin >= 60 ) { __iMin -= 60; __iHour += 1; }
170 __qDateTime.setTime( QTime( __iHour, __iMin, __iSec, __iMilli ) );
173 if( _pbOK ) *_pbOK =
true;
174 return( (
double)__qDateTime.toTime_t() + (double)__qDateTime.time().msec()/1000.0 );
[UI] Container for the application's settings
CUnitTime::EUnit getUnitTime()
[Unit] Returns the time format/unit
int getPrecisionTime()
[Precision] Returns the time decimal precision
CUnitTimeZone::EUnit getUnitTimeZone()
[Unit] Returns the timezone format/unit
Container class for supported machine-friendly format/unit codes.
QMap< CUnitTime::EUnit, QString > qMapCodes
Container class for supported human-readable format/unit symbols.
QMap< CUnitTime::EUnit, QString > qMapSymbols
@ UTC
Universal Time Coordinates.
static double fromString(const QString &_rqString, double _fdDate, CUnitTimeZone::EUnit _eUnitTimeZone, bool *_pbOK=0)
Returns the numeric value corresponding (parsed) from the string.
static QString toString(double _fdValue, CUnitTimeZone::EUnit _eUnitTimeZone, EUnit _eUnit, int _iPrecision=0)
Returns the formatted represention of the given value, using the specified format/unit and decimal pr...
static const CUnitTimeCodes oUnitTimeCodes
Container for supported machine-friendly format/unit codes.
@ UNDEFINED
undefined format/unit
static EUnit fromSymbol(const QString &_rqsSymbol)
Returns the format/unit ID corresponding to the given human-readable symbol.
static const CUnitTimeSymbols oUnitTimeSymbols
Container for supported human-readable format/unit symbols.
static const QMap< EUnit, QString > & codes()
Returns the list of supported machine-friendly format/unit codes.
static QString toSymbol(EUnit _eUnit)
Returns the human-readable symbol corresponding to the given format/unit ID.
static const QMap< EUnit, QString > & symbols()
Returns the list of supported human-readable format/unit symbols.
static EUnit fromCode(const QString &_rqsCode)
Returns the format/unit ID corresponding to the given machine-friendly code.
static QString toCode(EUnit _eUnit)
Returns the machine-friendly code corresponding to the given format/unit ID.
static double toValue(double _fdValue, CUnitTimeZone::EUnit _eUnitTimeZone)
Returns the converted value, using the specified format/unit.
static CSettings * useSettings()