Present  0.9
 All Classes Files Functions Variables Typedefs Friends Macros Pages
types.h
Go to the documentation of this file.
1 /*
2  * Present - Date/Time Library
3  *
4  * Definitions of common types used throughout Present
5  *
6  * Licensed under the MIT License.
7  * For details, see LICENSE.
8  */
9 
10 #include "present-config.h"
11 
12 #ifndef _PRESENT_TYPES_H_
13 #define _PRESENT_TYPES_H_
14 
15 /*
16  * Typedefs for Present boolean type (present_bool)
17  */
18 
19 #ifdef __cplusplus
20 /* This is C++; we have nice things like "bool" */
21 typedef bool present_bool;
22 #else
23 # ifdef PRESENT_USE_STDBOOL
24 /* At least C99 (so we have _Bool) */
25 typedef _Bool present_bool;
26 # else
27 /* We ain't got nothing */
28 typedef unsigned char present_bool;
29 # endif
30 #endif
31 
32 /*
33  * Include typedefs for Present int types
34  */
35 
36 #ifdef PRESENT_USE_STDINT
37 # include "present/internal/typedefs-stdint.h"
38 #else
39 # include "present/internal/typedefs-nostdint.h"
40 #endif
41 
42 /*
43  * Typedefs for common components of dates and times
44  *
45  * NOTE: Integer types are at least 16-bit, and signed, to make calculations
46  * (when adding/subtracting deltas) easier. Also, if we use 8-bit integers,
47  * it's usually a typedef of "char", and thus they are treated as characters
48  * in certain C++ overloads where they should be treated as integers.
49  */
50 
51 /* Timestamp */
52 
53 typedef present_int64 int_timestamp;
54 
55 /* Time (only used to describe parameters, not used for internal storage) */
56 
57 typedef present_int16 int_hour;
58 typedef present_int16 int_minute;
59 typedef present_int16 int_second;
60 typedef present_int64 int_nanosecond;
61 
62 /* Date */
63 
64 typedef present_int32 int_year;
65 typedef present_int16 int_month;
66 typedef present_int16 int_day;
67 typedef present_int16 int_day_of_year;
68 typedef present_int8 int_week_of_year;
69 
70 typedef present_uint8 int_day_of_week;
71 
72 /* NOTE: 0 is also a valid identifier for Sunday to be compatible with the
73  `struct tm` definition, but the ISO8601 definition (using 7 for Sunday)
74  is preferred. */
75 #define DAY_OF_WEEK_SUNDAY_COMPAT (0)
76 #define DAY_OF_WEEK_MONDAY (1)
77 #define DAY_OF_WEEK_TUESDAY (2)
78 #define DAY_OF_WEEK_WEDNESDAY (3)
79 #define DAY_OF_WEEK_THURSDAY (4)
80 #define DAY_OF_WEEK_FRIDAY (5)
81 #define DAY_OF_WEEK_SATURDAY (6)
82 #define DAY_OF_WEEK_SUNDAY (7)
83 
84 /* Time/Day Delta */
85 
86 typedef present_int64 int_delta;
87 
88 /* Month Delta */
89 
90 typedef present_int32 int_month_delta;
91 typedef present_int32 int_year_delta;
92 
93 #endif /* _PRESENT_TYPES_H_ */
94 
present_int64 int_nanosecond
Definition: types.h:60
present_int32 int_year_delta
Definition: types.h:91
present_int64 int_timestamp
Definition: types.h:53
present_int16 int_day
Definition: types.h:66
present_int32 int_year
Definition: types.h:64
present_int16 int_second
Definition: types.h:59
present_int64 int_delta
Definition: types.h:86
present_uint8 int_day_of_week
Definition: types.h:70
present_int16 int_month
Definition: types.h:65
present_int32 int_month_delta
Definition: types.h:90
present_int16 int_minute
Definition: types.h:58
present_int8 int_week_of_year
Definition: types.h:68
present_int16 int_hour
Definition: types.h:57
bool present_bool
Definition: types.h:21
present_int16 int_day_of_year
Definition: types.h:67