diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-11-14 21:53:55 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-11-14 21:53:55 +0000 |
commit | f31c7ff9571522bfc066da81a43a92dc925cb71c (patch) | |
tree | ce9fa8743fa00bca299ed2e75f7516a1aaf2a928 /include | |
parent | 00e9ca7148936b16b9547f71b1c9501d41f7f034 (diff) | |
download | llvm-f31c7ff9571522bfc066da81a43a92dc925cb71c.tar.gz llvm-f31c7ff9571522bfc066da81a43a92dc925cb71c.tar.bz2 llvm-f31c7ff9571522bfc066da81a43a92dc925cb71c.tar.xz |
*Make naming convention consistent.*Add convertion to/from Unix Epoch time.*Add ability to convert to readable string.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17762 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/System/TimeValue.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/include/llvm/System/TimeValue.h b/include/llvm/System/TimeValue.h index 71afd863f0..6e5e271c98 100644 --- a/include/llvm/System/TimeValue.h +++ b/include/llvm/System/TimeValue.h @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/DataTypes.h" +#include <string> #ifndef LLVM_SYSTEM_TIMEVALUE_H #define LLVM_SYSTEM_TIMEVALUE_H @@ -238,16 +239,22 @@ namespace sys { /// Converts the TimeValue into the corresponding number of "ticks" for /// Posix, correcting for the difference in Posix zero time. /// @brief Convert to unix time (100 nanoseconds since 12:00:00a Jan 1,1970) - uint64_t ToPosixTime( void ) const { + uint64_t toPosixTime( void ) const { uint64_t result = seconds_ - PosixZeroTime.seconds_; result += nanos_ / NANOSECONDS_PER_POSIX_TICK; return result; } + /// Converts the TimeValue into the corresponding number of seconds + /// since the epoch (00:00:00 Jan 1,1970). + uint64_t toEpochTime(void) const { + return seconds_ - PosixZeroTime.seconds_; + } + /// Converts the TiemValue into the correspodning number of "ticks" for /// Win32 platforms, correcting for the difference in Win32 zero time. /// @brief Convert to windows time (seconds since 12:00:00a Jan 1, 1601) - uint64_t ToWin32Time( void ) const { + uint64_t toWin32Time( void ) const { uint64_t result = seconds_ - Win32ZeroTime.seconds_; result += nanos_ / NANOSECONDS_PER_WIN32_TICK; return result; @@ -256,11 +263,16 @@ namespace sys { /// Provides the seconds and nanoseconds as results in its arguments after /// correction for the Posix zero time. /// @brief Convert to timespec time (ala POSIX.1b) - void GetTimespecTime( uint64_t& seconds, uint32_t& nanos ) const { + void getTimespecTime( uint64_t& seconds, uint32_t& nanos ) const { seconds = seconds_ - PosixZeroTime.seconds_; nanos = nanos_; } + /// Provides conversion of the TimeValue into a readable time & date. + /// @returns std::string containing the readable time value + /// @brief Convert time to a string. + std::string toString(); + /// @} /// @name Mutators /// @{ @@ -318,7 +330,7 @@ namespace sys { /// Converts the \p seconds argument from PosixTime to the corresponding /// TimeValue and assigns that value to \p this. /// @brief Convert seconds form PosixTime to TimeValue - void fromPosixTime( SecondsType seconds ) { + void fromEpochTime( SecondsType seconds ) { seconds_ = seconds + PosixZeroTime.seconds_; nanos_ = 0; this->normalize(); |