Ticket #5428: boost central time wrapper.patch
File boost central time wrapper.patch, 3.3 KB (added by , 11 years ago) |
---|
-
c_time.hpp
57 57 static std::tm* localtime(const std::time_t* t, std::tm* result) 58 58 { 59 59 // localtime_r() not in namespace std??? 60 61 62 63 64 65 *result = tmp;66 60 #if defined(__VMS) && __INITIAL_POINTER_SIZE == 64 61 std::tm tmp; 62 if(!localtime_r(t,&tmp)) 63 result = 0; 64 else 65 *result = tmp; 66 #else 67 67 result = localtime_r(t, result); 68 68 #endif 69 69 if (!result) 70 70 boost::throw_exception(std::runtime_error("could not convert calendar time to local time")); 71 71 return result; … … 75 75 static std::tm* gmtime(const std::time_t* t, std::tm* result) 76 76 { 77 77 // gmtime_r() not in namespace std??? 78 79 80 78 #if defined(__VMS) && __INITIAL_POINTER_SIZE == 64 79 std::tm tmp; 80 if(!gmtime_r(t,&tmp)) 81 81 result = 0; 82 82 else 83 *result = tmp; 84 83 *result = tmp; 84 #else 85 85 result = gmtime_r(t, result); 86 86 #endif 87 87 if (!result) 88 88 boost::throw_exception(std::runtime_error("could not convert calendar time to UTC time")); 89 89 return result; 90 90 } 91 #else // BOOST_HAS_THREADS91 #else 92 92 93 93 #if (defined(_MSC_VER) && (_MSC_VER >= 1400)) 94 94 #pragma warning(push) // preserve warning settings … … 116 116 #pragma warning(pop) // restore warnings to previous state 117 117 #endif // _MSC_VER >= 1400 118 118 119 #endif // BOOST_HAS_THREADS 119 #endif 120 121 std::time_t time(std::time_t* t) 122 { 123 return std::time(t); 124 } 120 125 }; 121 126 }} // namespaces 122 127 -
date_clock_device.hpp
58 58 private: 59 59 static ::std::tm* get_local_time(std::tm& result) 60 60 { 61 ::std::time_t t; 62 ::std::time(&t); 61 ::std::time_t t = c_time::time(0); 63 62 return c_time::localtime(&t, &result); 64 63 } 65 64 static ::std::tm* get_universal_time(std::tm& result) 66 65 { 67 ::std::time_t t; 68 ::std::time(&t); 66 ::std::time_t t = c_time::time(0); 69 67 return c_time::gmtime(&t, &result); 70 68 } 71 69 -
time_clock.hpp
32 32 33 33 static time_type local_time() 34 34 { 35 ::std::time_t t; 36 ::std::time(&t); 35 ::std::time_t t = c_time::time(0); 37 36 ::std::tm curr, *curr_ptr; 38 //curr_ptr = ::std::localtime(&t);39 37 curr_ptr = c_time::localtime(&t, &curr); 40 38 return create_time(curr_ptr); 41 39 } … … 45 43 static time_type universal_time() 46 44 { 47 45 48 ::std::time_t t; 49 ::std::time(&t); 46 ::std::time_t t = c_time::time(0); 50 47 ::std::tm curr, *curr_ptr; 51 //curr_ptr = ::std::gmtime(&t);52 48 curr_ptr = c_time::gmtime(&t, &curr); 53 49 return create_time(curr_ptr); 54 50 }