A high precision time class without limitation (e.g. 1970-01-01) More...
#include <DateTime.h>
Public Member Functions | |
void | addDays (int d) |
void | addHours (int h) |
void | addMinutes (int m) |
void | addMonths (int m) |
void | addSeconds (double s) |
void | addYears (int y) |
QDate | date () const |
DateTime () | |
DateTime (const QDateTime &dt) | |
DateTime (const DateTime &o) | |
QDateTime | dateTime () const |
double | fractions () const |
bool | fromString (const QString &text, const QString &format) |
void | fromTime_t (time_t t) |
void | fromTime_t (QString t) |
int | hour () const |
bool | isNull () const |
int | minute () const |
bool | operator!= (const DateTime &o) |
bool | operator< (const DateTime &o) |
void | operator= (const DateTime &o) |
bool | operator== (const DateTime &o) |
bool | operator> (const DateTime &o) |
int | second () const |
double | secondsTo (const DateTime &o) const |
bool | setDate (int year=1900, int month=1, int day=1) |
void | setDate (const QDate &d) |
void | setDateTime (const QDateTime &dt) |
bool | setTime (int hour=0, int minute=0, int second=0, double fractions=0.0) |
QString | toString (const QString &format, int precision=6) const |
time_t | toTime_t () const |
QString | toTime_t (int precision) const |
~DateTime () | |
Static Public Member Functions | |
static TIME | capAddSecs (QDateTime dt, double secs) |
A high precision time class without limitation (e.g. 1970-01-01)
It is based upon QDate for calendar operations (e.g. handling of leap years). Calendar limitation are those of QDate, i.e., from January 2nd, 4713 BCE, to sometime in the year 11 million CE. Leap seconds are currently not handled (TODO in a future release). Fraction of seconds are stored as double offering a precision much smaller than nanoseconds. Local time is not considered, all times are considered as UTC.
QGpCoreTools::DateTime::DateTime | ( | ) | [inline] |
{_d=new DateTimeData;}
QGpCoreTools::DateTime::DateTime | ( | const QDateTime & | dt | ) | [inline] |
{_d=new DateTimeData(dt);}
QGpCoreTools::DateTime::DateTime | ( | const DateTime & | o | ) | [inline] |
: _d(o._d) {}
QGpCoreTools::DateTime::~DateTime | ( | ) | [inline] |
{}
void QGpCoreTools::DateTime::addDays | ( | int | d | ) | [inline] |
Referenced by GeopsyCore::PasscalSegYHeader::t0(), and GeopsyCore::PasscalSegYHeader::timePick().
{_d->addDays(d);}
void QGpCoreTools::DateTime::addHours | ( | int | h | ) | [inline] |
{_d->addHours(h);}
void QGpCoreTools::DateTime::addMinutes | ( | int | m | ) | [inline] |
{_d->addMinutes(m);}
void QGpCoreTools::DateTime::addMonths | ( | int | m | ) | [inline] |
{_d->addMonths(m);}
void QGpCoreTools::DateTime::addSeconds | ( | double | s | ) | [inline] |
Referenced by GeopsyCore::CitySignal::readHeader(), Process::run(), GeopsyCore::PasscalSegYHeader::t0(), GeopsyCore::PasscalSegYHeader::timePick(), and GeopsyCore::Signal::writeGse().
{_d->addSeconds(s);}
void QGpCoreTools::DateTime::addYears | ( | int | y | ) | [inline] |
{_d->addYears(y);}
TIME QGpCoreTools::DateTime::capAddSecs | ( | QDateTime | dt, |
double | secs | ||
) | [static] |
Add secs seconds to dt and returns a Pitsa TIME structure.
References QGpCoreTools::PitsaTime::day, QGpCoreTools::PitsaTime::hr, QGpCoreTools::PitsaTime::mn, QGpCoreTools::PitsaTime::mo, QGpCoreTools::PitsaTime::sec, TRACE, and QGpCoreTools::PitsaTime::yr.
{ TRACE; // Positive number rounded to inferior integer, neg to superior int nSecs=(int)floor(secs); // msecs is allways positive and less than 1 double msecs=secs-nSecs; dt=dt.addSecs(nSecs); TIME t; t.yr=dt.date().year(); t.mo=dt.date().month(); t.day=dt.date().day(); t.hr=dt.time().hour(); t.mn=dt.time().minute(); t.sec=(float)dt.time().second()+msecs; return t; }
QDate QGpCoreTools::DateTime::date | ( | ) | const [inline] |
{return _d->date();}
QDateTime QGpCoreTools::DateTime::dateTime | ( | ) | const [inline] |
Referenced by GeopsyCore::CitySignal::loadSignals(), and Process::run().
{return _d->dateTime();}
double QGpCoreTools::DateTime::fractions | ( | ) | const [inline] |
Referenced by GeopsyCore::CitySignal::loadSignals().
{return _d->fractions();}
bool QGpCoreTools::DateTime::fromString | ( | const QString & | text, |
const QString & | format | ||
) | [inline] |
Referenced by GeopsyCore::CitySignal::readHeader(), and Process::setArguments().
{return _d->fromString(text, format);}
void QGpCoreTools::DateTime::fromTime_t | ( | time_t | t | ) | [inline] |
{_d->fromTime_t(t);}
void QGpCoreTools::DateTime::fromTime_t | ( | QString | t | ) | [inline] |
{_d->fromTime_t(t);}
int QGpCoreTools::DateTime::hour | ( | ) | const [inline] |
{return _d->hour();}
bool QGpCoreTools::DateTime::isNull | ( | ) | const [inline] |
{return _d->isNull();}
int QGpCoreTools::DateTime::minute | ( | ) | const [inline] |
{return _d->minute();}
bool QGpCoreTools::DateTime::operator!= | ( | const DateTime & | o | ) | [inline] |
{return *_d!=*o._d;}
bool QGpCoreTools::DateTime::operator< | ( | const DateTime & | o | ) | [inline] |
{return *_d<*o._d;}
void QGpCoreTools::DateTime::operator= | ( | const DateTime & | o | ) | [inline] |
{return *_d=*o._d;}
bool QGpCoreTools::DateTime::operator== | ( | const DateTime & | o | ) | [inline] |
{return *_d==*o._d;}
bool QGpCoreTools::DateTime::operator> | ( | const DateTime & | o | ) | [inline] |
{return *_d>*o._d;}
int QGpCoreTools::DateTime::second | ( | ) | const [inline] |
{return _d->second();}
double QGpCoreTools::DateTime::secondsTo | ( | const DateTime & | o | ) | const [inline] |
Referenced by GeopsyCore::CitySignal::loadSignals(), and Process::run().
{return _d->secondsTo(*o._d);}
bool QGpCoreTools::DateTime::setDate | ( | int | year = 1900 , |
int | month = 1 , |
||
int | day = 1 |
||
) | [inline] |
{return _d->setDate(year, month, day);}
void QGpCoreTools::DateTime::setDate | ( | const QDate & | d | ) | [inline] |
{_d->setDate(d);}
void QGpCoreTools::DateTime::setDateTime | ( | const QDateTime & | dt | ) | [inline] |
Referenced by Process::run().
{_d->setDateTime(dt);}
bool QGpCoreTools::DateTime::setTime | ( | int | hour = 0 , |
int | minute = 0 , |
||
int | second = 0 , |
||
double | fractions = 0.0 |
||
) | [inline] |
QString QGpCoreTools::DateTime::toString | ( | const QString & | format, |
int | precision = 6 |
||
) | const [inline] |
Referenced by GeopsyGui::CitySignalItem::data(), GeopsyCore::CitySignal::loadSignals(), Process::run(), and GeopsyCore::Signal::writeGse().
{return _d->toString(format, precision);}
time_t QGpCoreTools::DateTime::toTime_t | ( | ) | const [inline] |
{return _d->toTime_t();}
QString QGpCoreTools::DateTime::toTime_t | ( | int | precision | ) | const [inline] |
{return _d->toTime_t(precision);}