GRU - Generic Reusable Utilities
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
gru_duration.h
Go to the documentation of this file.
1 /*
2  Copyright 2016 Otavio Rodolfo Piske
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15  */
16 #ifndef GRU_DURATION_H
17 #define GRU_DURATION_H
18 
19 #include <math.h>
20 #include <stdlib.h>
21 
22 #if !defined(_WIN32) && !defined(_WIN64)
23 #include <sys/time.h>
24 #else
25 #include <windows.h>
26 #endif
27 
28 #include "common/gru_portable.h"
29 #include "gru_time_utils.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 typedef struct gru_duration_t_ {
36  struct timeval start;
37  struct timeval end;
39 
47 
55 
63 
70 gru_export uint64_t gru_duration_minutes(gru_duration_t duration, double *fractional);
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif /* GRU_DURATION_H */
struct timeval end
Definition: gru_duration.h:37
Definition: gru_duration.h:35
uint64_t gru_duration_minutes(gru_duration_t duration, double *fractional)
Given a duration object, return the number of minutes between its start and end time.
Definition: gru_duration.c:44
#define gru_export
Definition: gru_portable.h:19
gru_duration_t gru_duration_from_seconds(uint64_t seconds)
Builds a duration struct that represents a duration.
Definition: gru_duration.c:18
struct gru_duration_t_ gru_duration_t
uint64_t gru_duration_seconds(gru_duration_t duration)
Given a duration object, return the number of seconds between its start and end time.
Definition: gru_duration.c:40
struct timeval start
Definition: gru_duration.h:36
gru_duration_t gru_duration_from_minutes(uint64_t minutes)
Builds a duration struct that represents a duration.
Definition: gru_duration.c:29