*Make naming convention consistent.*Add convertion to/from Unix Epoch time.*Add abili...
authorReid Spencer <rspencer@reidspencer.com>
Sun, 14 Nov 2004 21:53:55 +0000 (21:53 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Sun, 14 Nov 2004 21:53:55 +0000 (21:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17762 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/System/TimeValue.h

index 71afd863f0e92ec66ed6a53b9933e7e11ce49c3b..6e5e271c98e46e269f2157e1e7f3079e9974001e 100644 (file)
@@ -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();