susumu.yata
null+****@clear*****
Thu Feb 28 16:16:31 JST 2013
susumu.yata 2013-02-28 16:16:31 +0900 (Thu, 28 Feb 2013) New Revision: 518306f7d40bfa0152825146c476f80a84961ff5 https://github.com/groonga/grnxx/commit/518306f7d40bfa0152825146c476f80a84961ff5 Log: Remove unused headers and use grnxx::BrokenDownTime in write_to(). Modified files: lib/time.cpp Modified: lib/time.cpp (+1 -40) =================================================================== --- lib/time.cpp 2013-02-28 15:08:33 +0900 (3678f5c) +++ lib/time.cpp 2013-02-28 16:16:31 +0900 (2011851) @@ -17,22 +17,9 @@ */ #include "time.hpp" -#ifdef GRNXX_WINDOWS -# include <sys/types.h> -# include <sys/timeb.h> -#endif // GRNXX_WINDOWS - -#ifndef GRNXX_HAS_CLOCK_GETTIME -# include <sys/time.h> -#endif // GRNXX_HAS_CLOCK_GETTIME - -#include <cerrno> #include <ctime> #include <ostream> -#include "error.hpp" -#include "intrinsic.hpp" -#include "logger.hpp" #include "lock.hpp" #include "string_format.hpp" @@ -112,33 +99,7 @@ StringBuilder &Time::write_to(StringBuilder &builder) const { return builder; } - const std::time_t posix_time = static_cast<std::time_t>(count_ / 1000000); - struct tm broken_down_time; -#ifdef GRNXX_MSC - if (::localtime_s(&posix_time, &broken_down_time) != 0) { - return builder << "0000-00-00 00:00:00.000000"; - } -#elif defined(GRNXX_HAS_LOCALTIME_R) - if (::localtime_r(&posix_time, &broken_down_time) == nullptr) { - return builder << "0000-00-00 00:00:00.000000"; - } -#else // defined(GRNXX_HAS_LOCALTIME_R) - // TODO: should be thread-safe. - struct tm * const global_broken_down_time = ::localtime(&posix_time); - if (global_broken_down_time == nullptr) { - return builder << "0000-00-00 00:00:00.000000"; - } - broken_down_time = *global_broken_down_time; -#endif // defined(GRNXX_HAS_LOCALTIME_R) - - builder << (1900 + broken_down_time.tm_year) << '-' - << StringFormat::align_right(broken_down_time.tm_mon + 1, 2, '0') << '-' - << StringFormat::align_right(broken_down_time.tm_mday, 2, '0') << ' ' - << StringFormat::align_right(broken_down_time.tm_hour, 2, '0') << ':' - << StringFormat::align_right(broken_down_time.tm_min, 2, '0') << ':' - << StringFormat::align_right(broken_down_time.tm_sec, 2, '0') << '.' - << StringFormat::align_right(count_ % 1000000, 6, '0'); - return builder; + return builder << local_time(); } std::ostream &operator<<(std::ostream &stream, Time time) { -------------- next part -------------- HTML����������������������������...Download