#include <Time.h>
Public Member Functions | |
Time () | |
Time (time_t sec, long nsec) | |
Build time from seconds and nanoseconds. | |
~Time () | |
Destructor. | |
time_t | sec () const |
return seconds | |
long | nsec () const |
return nanoseconds | |
bool | isValid () const |
check if the time is valid | |
std::string | toString () const throw (Exception) |
std::string | toString (const std::string &fmt) const throw (Exception) |
Static Public Member Functions | |
static Time | now () |
Returns current time. | |
static Time | parse (const std::string &inTimeStr) throw (Exception) |
static Time | from64 (uint64_t inNumber) throw (Exception) |
static uint64_t | to64 (const Time &inTime) throw (Exception) |
This software was developed for the LUSI project. If you use all or part of it, please give an appropriate acknowledgment.
Definition at line 54 of file Time.h.
LusiTime::Time::Time | ( | time_t | sec, | |
long | nsec | |||
) | [inline] |
Unpack a 64-bit number into time
A number on the input is supposed to be a previously packed value of an object of the current class.
The overflow is reported through the exception
Referenced by LogBook::QueryProcessor::get().
bool LusiTime::Time::isValid | ( | ) | const [inline] |
check if the time is valid
Definition at line 132 of file Time.h.
Referenced by BOOST_AUTO_TEST_CASE(), LogBook::ConnectionImpl::createRun(), LogBook::ConnectionImpl::endRun(), LusiTime::operator!=(), LusiTime::operator<(), LusiTime::operator<=(), LusiTime::operator==(), LusiTime::operator>(), and LusiTime::operator>=().
static Time LusiTime::Time::now | ( | ) | [static] |
Returns current time.
Referenced by LogBook::ConnectionImpl::allocateRunNumber(), Translator::H5Output::createH5OutputFile(), Translator::H5Output::event(), XtcInput::XtcChunkDgIter::nextAtOffset(), LogBook::ConnectionImpl::reportOpenFile(), Translator::H5Output::reportRunTime(), Translator::H5MpiTranslateApp::runApp(), Translator::H5MpiTranslateApp::runAppMaster(), and Translator::H5MpiTranslateApp::runAppWorker().
long LusiTime::Time::nsec | ( | ) | const [inline] |
return nanoseconds
Definition at line 129 of file Time.h.
Referenced by BOOST_AUTO_TEST_CASE(), Translator::H5Output::event(), LusiTime::operator!=(), LusiTime::operator<(), LusiTime::operator<=(), LusiTime::operator==(), LusiTime::operator>(), LusiTime::operator>=(), Translator::H5Output::reportRunTime(), and timeDiffSeconds().
Parse an input string as the date and time.
If successful then the method will return a valid object of the current class. Otherwise an exception will be thrown.
The input string is expected to have on of the the following formats:
<year>-<month>-<day> <hours>:<minutes>:<seconds>[.<fractions>][<tz>] <year>-<month>-<day> <hours>:<minutes>:<seconds>[.<fractions>][<tz>] <year>-<month>-<day> <hours>:<minutes>[<tz>] <year>-<month>-<day> <hours>[<tz>] <year>-<month>-<day> - means 00:00:00 of the day <year>-<month> - means 00:00:00 of the 1st day of the month <year> - means 00:00:00 of the January 1st of the year S<seconds-since-epoch>[.<fractions>]
Date/time separators (- and :) are optional. Date and time can be separated by any number of spaces or a single 'T' character. Timezone offset <tz> can be either 'Z' for UTC, or {+|-}HH[[:]MM]
Few examples of valid input:
2009-06-05 2009-06-05 10:12:32 2009-06-05T10:12:32Z 2009-06-05T10:12:32.123-08 2009-06-05T10:12-08:00 20090605T101232.123+0100 S1234567890.001
time_t LusiTime::Time::sec | ( | ) | const [inline] |
return seconds
Definition at line 126 of file Time.h.
Referenced by BOOST_AUTO_TEST_CASE(), Translator::H5Output::event(), LusiTime::operator!=(), LusiTime::operator<(), LusiTime::operator<=(), LusiTime::operator==(), LusiTime::operator>(), LusiTime::operator>=(), Translator::H5Output::reportRunTime(), and timeDiffSeconds().
Pack time into a 64-bit number
An input timestamp must be valid. Otherwise an exception will be thrown.
Referenced by LogBook::ConnectionImpl::allocateRunNumber(), LogBook::ConnectionImpl::createRun(), LogBook::ConnectionImpl::endRun(), and LogBook::ConnectionImpl::reportOpenFile().
std::string LusiTime::Time::toString | ( | const std::string & | fmt | ) | const throw (Exception) |
Translate into the string representation according to given format. Format specifiers supported:
F = Y-m-d f fractions of second with preceding dot, default precision is 9, precision can be changed with %.Nf format H hour (00...24) j day of the year (001...366) m month (01...12) M minute (00...59) s seconds since epoch S seconds (00...60) T = H:M:S Y year z timezone %% literal %
If the object is not valid then the method will throw an exception.
std::string LusiTime::Time::toString | ( | ) | const throw (Exception) |
Translate into the string representation.
The output string will have the following format:
<year>-<month>-<day> <hours>:<minutes>:<seconds>.<nanoseconds><TZ>
Where the month will be represented by a number. For example:
2009-06-05 10:12:32.123456789-0800
If the object is not valid then the method will throw an exception.
Referenced by BOOST_AUTO_TEST_CASE(), and Translator::H5Output::createH5OutputFile().