[Groonga-commit] groonga/grnxx [master] Use (now() - from_time_t(0)) instead of time_since_epoch().

Back to archive index

susumu.yata null+****@clear*****
Fri Mar 1 18:07:43 JST 2013


susumu.yata	2013-03-01 18:07:43 +0900 (Fri, 01 Mar 2013)

  New Revision: 26896c57c2bba18d93e8b550a6bcf1e4c130dc36
  https://github.com/groonga/grnxx/commit/26896c57c2bba18d93e8b550a6bcf1e4c130dc36

  Log:
    Use (now() - from_time_t(0)) instead of time_since_epoch().
    
    Because the epoch of std::chrono::epoch is not guaranteed to be the Unix epoch.
    I believe time_t is more likely to be based on the Unix epoch.

  Modified files:
    lib/system_clock.cpp

  Modified: lib/system_clock.cpp (+4 -1)
===================================================================
--- lib/system_clock.cpp    2013-03-01 14:42:46 +0900 (d637dec)
+++ lib/system_clock.cpp    2013-03-01 18:07:43 +0900 (dfb1268)
@@ -22,8 +22,11 @@
 namespace grnxx {
 
 Time SystemClock::now() {
+  // The epoch of std::chrono::system_clock is not guaranteed to be the Unix
+  // epoch. So, (now() - from_time_t(0)) is used instead of time_since_epoch().
   return Time(std::chrono::duration_cast<std::chrono::microseconds>(
-              std::chrono::system_clock::now().time_since_epoch()).count());
+              (std::chrono::system_clock::now() -
+               std::chrono::system_clock::from_time_t(0))).count());
 }
 
 }  // namespace grnxx
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index