susumu.yata
null+****@clear*****
Thu Feb 28 16:32:02 JST 2013
susumu.yata 2013-02-28 16:32:02 +0900 (Thu, 28 Feb 2013) New Revision: 92681d30c840b46622b79795c415e5bd5d33c4bb https://github.com/groonga/grnxx/commit/92681d30c840b46622b79795c415e5bd5d33c4bb Log: Use grnxx::BrokenDownTime to output time in human-readble format. Modified files: lib/io/file_info.cpp lib/logger.cpp lib/recycler.cpp lib/time.cpp test/test_time.cpp Modified: lib/io/file_info.cpp (+6 -3) =================================================================== --- lib/io/file_info.cpp 2013-02-28 16:17:45 +0900 (ad22972) +++ lib/io/file_info.cpp 2013-02-28 16:32:02 +0900 (1e78abd) @@ -165,9 +165,12 @@ StringBuilder &Impl::write_to(StringBuilder &builder) const { << ", user_id = " << user_id() << ", group_id = " << group_id() << ", size = " << size() - << ", last_access_time = " << last_access_time() - << ", last_modification_time = " << last_modification_time() - << ", last_status_change_time = " << last_status_change_time() + << ", last_access_time = " + << last_access_time().local_time() + << ", last_modification_time = " + << last_modification_time().local_time() + << ", last_status_change_time = " + << last_status_change_time().local_time() << " }"; } Modified: lib/logger.cpp (+1 -1) =================================================================== --- lib/logger.cpp 2013-02-28 16:17:45 +0900 (1f06576) +++ lib/logger.cpp 2013-02-28 16:32:02 +0900 (2c5c095) @@ -175,7 +175,7 @@ void Logger::append_line_header() { const LoggerFlags flags = Logger::flags(); if (flags & LOGGER_WITH_DATE_TIME) { - builder_ << SystemClock::now() << ": "; + builder_ << SystemClock::now().local_time() << ": "; } if (flags & LOGGER_WITH_LOCATION) { builder_ << file_ << ':' << line_ << ": In " << func_ << "(): "; Modified: lib/recycler.cpp (+1 -1) =================================================================== --- lib/recycler.cpp 2013-02-28 16:17:45 +0900 (82aa0e6) +++ lib/recycler.cpp 2013-02-28 16:32:02 +0900 (282237a) @@ -97,7 +97,7 @@ StringBuilder &Recycler::write_to(StringBuilder &builder) const { if (stamp != stamp_pair.threshold) { builder << ", "; } - builder << '[' << stamp << "] = " << times_[time_id]; + builder << '[' << stamp << "] = " << times_[time_id].local_time(); } builder << " }"; Modified: lib/time.cpp (+13 -1) =================================================================== --- lib/time.cpp 2013-02-28 16:17:45 +0900 (2011851) +++ lib/time.cpp 2013-02-28 16:32:02 +0900 (2fd867c) @@ -99,7 +99,19 @@ StringBuilder &Time::write_to(StringBuilder &builder) const { return builder; } - return builder << local_time(); + uint64_t count; + if (count_ >= 0) { + count = count_; + } else { + builder << '-'; + count = -count_; + } + builder << (count / 1000000); + count %= 1000000; + if (count != 0) { + builder << '.' << StringFormat::align_right(count, 6, '0'); + } + return builder; } std::ostream &operator<<(std::ostream &stream, Time time) { Modified: test/test_time.cpp (+6 -2) =================================================================== --- test/test_time.cpp 2013-02-28 16:17:45 +0900 (0aaa151) +++ test/test_time.cpp 2013-02-28 16:32:02 +0900 (f6358d0) @@ -33,10 +33,14 @@ int main() { std::numeric_limits<std::int64_t>::min()); grnxx::Time time = grnxx::SystemClock::now(); - GRNXX_NOTICE() << "grnxx::SystemClock::now: " << time; + GRNXX_NOTICE() << "grnxx::SystemClock::now(): " << time; + GRNXX_NOTICE() << "grnxx::SystemClock::now().local_time(): " + << time.local_time(); time = grnxx::SteadyClock::now(); - GRNXX_NOTICE() << "grnxx::SteadyClock::now: " << time; + GRNXX_NOTICE() << "grnxx::SteadyClock::now(): " << time; + GRNXX_NOTICE() << "grnxx::SteadyClock::now().local_time(): " + << time.local_time(); enum { LOOP_COUNT = 1 << 16 }; -------------- next part -------------- HTML����������������������������... Download