Groonga
Loading...
Searching...
No Matches
time.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Brazil
3 Copyright (C) 2022 Sutou Kouhei <kou@clear-code.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19
20#pragma once
21
22#include <time.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#define GRN_TIMEVAL_TO_MSEC(timeval) \
29 (((timeval)->tv_sec * GRN_TIME_MSEC_PER_SEC) + \
30 ((timeval)->tv_nsec / GRN_TIME_NSEC_PER_MSEC))
31
32#define GRN_TIMEVAL_TO_NSEC(timeval) \
33 (((timeval)->tv_sec * GRN_TIME_NSEC_PER_SEC) + (timeval)->tv_nsec)
34
35#define GRN_TIME_NSEC_PER_SEC 1000000000
36#define GRN_TIME_NSEC_PER_SEC_F 1000000000.0
37#define GRN_TIME_NSEC_PER_MSEC 1000000
38#define GRN_TIME_NSEC_PER_USEC 1000
39#define GRN_TIME_NSEC_TO_USEC(nsec) ((nsec) / GRN_TIME_NSEC_PER_USEC)
40#define GRN_TIME_USEC_TO_NSEC(usec) ((usec) * GRN_TIME_NSEC_PER_USEC)
41
42#define GRN_TIME_MSEC_PER_SEC 1000
43
44#define GRN_TIME_USEC_PER_SEC 1000000
45#define GRN_TIME_USEC_PER_SEC_F 1000000.0
46#define GRN_TIME_USEC_PER_MSEC 1000
47#define GRN_TIME_USEC_TO_SEC(usec) ((usec) / GRN_TIME_USEC_PER_SEC)
48
49#define GRN_TIME_MSEC_TO_USEC(msec) ((msec) * GRN_TIME_USEC_PER_MSEC)
50
51#define GRN_TIME_PACK(sec, usec) ((int64_t)(sec) * GRN_TIME_USEC_PER_SEC + (usec))
52#define GRN_TIME_UNPACK(time_value, sec, usec) do {\
53 sec = (time_value) / GRN_TIME_USEC_PER_SEC;\
54 usec = (int32_t)((time_value) % GRN_TIME_USEC_PER_SEC);\
55} while (0)
56
59
61
62#define GRN_TIME_NOW(ctx,obj) (grn_time_now((ctx), (obj)))
63
65 int64_t time,
66 struct tm *tm);
68 int64_t *time,
69 struct tm *tm);
70
71#ifdef __cplusplus
72}
73#endif
grn_rc
Definition groonga.h:61
#define GRN_API
Definition groonga.h:39
Definition groonga.h:351
Definition groonga.h:919
Definition groonga.h:3341
GRN_API void grn_time_now(grn_ctx *ctx, grn_obj *obj)
GRN_API bool grn_time_from_tm(grn_ctx *ctx, int64_t *time, struct tm *tm)
GRN_API bool grn_time_to_tm(grn_ctx *ctx, int64_t time, struct tm *tm)
GRN_API grn_rc grn_timeval_now(grn_ctx *ctx, grn_timeval *tv)
GRN_API grn_timeval grn_timeval_from_double(grn_ctx *ctx, double value)