[Groonga-mysql-commit] mroonga/mroonga [master] Fix wrong UNIX epoch time year

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Oct 24 22:57:05 JST 2012


Kouhei Sutou	2012-10-24 22:57:05 +0900 (Wed, 24 Oct 2012)

  New Revision: aeae8c759c7520d1fda1d3ac3e2e728aa4c25e60
  https://github.com/mroonga/mroonga/commit/aeae8c759c7520d1fda1d3ac3e2e728aa4c25e60

  Log:
    Fix wrong UNIX epoch time year

  Modified files:
    ha_mroonga.cpp

  Modified: ha_mroonga.cpp (+3 -1)
===================================================================
--- ha_mroonga.cpp    2012-10-24 22:56:00 +0900 (0037b88)
+++ ha_mroonga.cpp    2012-10-24 22:57:05 +0900 (6ffdd9a)
@@ -115,6 +115,7 @@ extern pthread_mutex_t LOCK_open;
 static const char *index_column_name = "index";
 static const char *mrn_plugin_author = "The mroonga project";
 static const long long int TM_YEAR_BASE = 1900;
+static const long long int UNIX_EPOCH_TIME_YEAR = 1970;
 
 #ifdef __cplusplus
 extern "C" {
@@ -1509,7 +1510,8 @@ static long long int mrn_tm_to_grn_time(struct tm *time, int usec)
   long long int grn_time;
   long long int sec = mktime(time);
   bool failed = (sec == -1);
-  bool overflowed = (time->tm_year >= 0 && sec < 0);
+  bool overflowed = (time->tm_year >= (UNIX_EPOCH_TIME_YEAR - TM_YEAR_BASE) &&
+                     sec < 0);
   if (failed || overflowed) {
     grn_time = 0;
   } else {
-------------- next part --------------
HTML����������������������������...
Download 



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