1/* -*- c-basic-offset: 2 -*- */
2/*
3 Copyright(C) 2010-2013 Kentoku SHIBA
4 Copyright(C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19*/
20
21#ifndef MRN_TIME_CONVERTER_HPP_
22#define MRN_TIME_CONVERTER_HPP_
23
24#include <mrn_mysql_compat.h>
25
26#include <groonga.h>
27
28namespace mrn {
29 class TimeConverter {
30 public:
31 static const long long int TM_YEAR_BASE = 1900;
32
33 TimeConverter();
34 ~TimeConverter();
35
36 long long int mysql_time_to_grn_time(MYSQL_TIME *mysql_time,
37 bool *truncated);
38 long long int mysql_datetime_to_grn_time(long long int mysql_datetime,
39 bool *truncated);
40
41 long long int tm_to_grn_time(struct tm *time, int usec, bool *truncated);
42
43 void grn_time_to_mysql_time(long long int grn_time, MYSQL_TIME *mysql_time);
44 long long int grn_time_to_mysql_datetime(long long int grn_time);
45
46 private:
47 time_t tm_to_time_gm(struct tm *time, bool *truncated);
48 };
49}
50
51#endif /* MRN_TIME_CONVERTER_HPP_ */
52