1 /*
2 Copyright (C) 2015-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: dk4ftime.ctr
12 */
13 
14 #ifndef DK4FTIME_H_INCLUDED
15 /** Avoid multiple inclusions. */
16 #define DK4FTIME_H_INCLUDED 1
17 
18 
19 /**	@file
20 	File related timestamps (timestamp comparison, converstion to text.
21 */
22 
23 #ifndef DK4CONF_H_INCLUDED
24 #if DK4_BUILDING_DKTOOLS4
25 #include "dk4conf.h"
26 #else
27 #include <dktools-4/dk4conf.h>
28 #endif
29 #endif
30 
31 #ifndef DK4TYPES_H_INCLUDED
32 #if DK4_BUILDING_DKTOOLS4
33 #include <libdk4base/dk4types.h>
34 #else
35 #include <dktools-4/dk4types.h>
36 #endif
37 #endif
38 
39 #ifndef DK4ERROR_H_INCLUDED
40 #if DK4_BUILDING_DKTOOLS4
41 #include <libdk4base/dk4error.h>
42 #else
43 #include <dktools-4/dk4error.h>
44 #endif
45 #endif
46 
47 #ifndef DK4TIMEC_H_INCLUDED
48 #if DK4_BUILDING_DKTOOLS4
49 #include <libdk4c/dk4timec.h>
50 #else
51 #include <dktools-4/dk4timec.h>
52 #endif
53 #endif
54 
55 #if DK4_ON_WINDOWS
56 #ifndef WINDOWS_H_INCLUDED
57 #include <windows.h>
58 #define	WINDOWS_H_INCLUDED 1
59 #endif
60 #else
61 #if DK4_HAVE_SYS_TYPES_H
62 #ifndef SYS_TYPES_H_INCLUDED
63 #include <sys/types.h>
64 #define	SYS_TYPES_H_INCLUDED 1
65 #endif
66 #endif
67 #if DK4_TIME_WITH_SYS_TIME
68 #ifndef SYS_TIME_H_INCLUDED
69 #include <sys/time.h>
70 #define	SYS_TIME_H_INCLUDED 1
71 #endif
72 #ifndef TIME_H_INCLUDED
73 #include <time.h>
74 #define	TIME_H_INCLUDED 1
75 #endif
76 #else
77 #if DK4_HAVE_TIME_H
78 #ifndef TIME_H_INCLUDED
79 #include <time.h>
80 #define	TIME_H_INCLUDED 1
81 #endif
82 #else
83 #if DK4_HAVE_SYS_TIME_H
84 #ifndef SYS_TIME_H_INCLUDED
85 #include <sys/time.h>
86 #define	SYS_TIME_H_INCLUDED 1
87 #endif
88 #endif
89 #endif
90 #endif
91 #ifndef DK4TIME_H_INCLUDED
92 #if DK4_BUILDING_DKTOOLS4
93 #include <libdk4c/dk4time.h>
94 #else
95 #include <dktools-4/dk4time.h>
96 #endif
97 #endif
98 #endif
99 
100 
101 
102 #if DK4_ON_WINDOWS
103 /**	File related timestamp.
104 */
105 typedef	FILETIME	dk4_file_time_t;
106 #else
107 /**	File related timestamp.
108 */
109 typedef	dk4_time_t	dk4_file_time_t;
110 #endif
111 
112 
113 
114 #ifdef __cplusplus
115 extern "C" {
116 #endif
117 
118 /**	Compare two timestamps.
119 	CRT on Windows: Not used.
120 	@param	l	Left timestamp.
121 	@param	r	Right timestamp.
122 	@return	1 if l>r, 0 if l=r, -1 if l<r.
123 */
124 int
125 dk4filetime_compare(const dk4_file_time_t *l, const dk4_file_time_t *r);
126 
127 /**	Convert timestamp to text ``yyyy-mm-dd hh:mm:ss''.
128 	CRT on Windows: Optional.
129 	@param	dptr	Result buffer address.
130 	@param	dsz	Result buffer size (number of dkChar).
131 	@param	fit	Timestamp to convert.
132 	@param	erp	Error report, may be NULL.
133 	@return 1 on success, 0 on error.
134 
135 	Error codes:
136 	- DK4_E_INVALID_ARGUMENTS<br>
137 	  if dptr or fit is NULL or dsz is 0,
138 	- DK4_E_MATH_OVERFLOW<br>
139 	  if a mathematical overflow occures in a size calculation,
140 	- DK4_E_BUFFER_TOO_SMALL<br>
141 	  if the buffer is too small,
142 	- DK4_E_BUG<br>
143 	  if CRT or Windows API functions failed to convert the timestamp to
144 	  local time information.
145 */
146 int
147 dk4filetime_to_text_c8(
148   char			*dptr,
149   size_t		 dsz,
150   const dk4_file_time_t	*fit,
151   dk4_er_t		*erp
152 );
153 
154 /**	Convert timestamp to text ``yyyy-mm-dd hh:mm:ss''.
155 	CRT on Windows: Optional.
156 	@param	dptr	Result buffer address.
157 	@param	dsz	Result buffer size (number of dkChar).
158 	@param	fit	Timestamp to convert.
159 	@param	erp	Error report, may be NULL.
160 	@return 1 on success, 0 on error.
161 
162 	Error codes:
163 	- DK4_E_INVALID_ARGUMENTS<br>
164 	  if dptr or fit is NULL or dsz is 0,
165 	- DK4_E_MATH_OVERFLOW<br>
166 	  if a mathematical overflow occures in a size calculation,
167 	- DK4_E_BUFFER_TOO_SMALL<br>
168 	  if the buffer is too small,
169 	- DK4_E_BUG<br>
170 	  if CRT or Windows API functions failed to convert the timestamp to
171 	  local time information.
172 */
173 int
174 dk4filetime_to_text_wc(
175   wchar_t		*dptr,
176   size_t		 dsz,
177   const dk4_file_time_t	*fit,
178   dk4_er_t		*erp
179 );
180 
181 /**	Convert timestamp to text ``yyyy-mm-dd hh:mm:ss''.
182 	CRT on Windows: Optional.
183 	@param	dptr	Result buffer address.
184 	@param	dsz	Result buffer size (number of dkChar).
185 	@param	fit	Timestamp to convert.
186 	@param	erp	Error report, may be NULL.
187 	@return 1 on success, 0 on error.
188 
189 	Error codes:
190 	- DK4_E_INVALID_ARGUMENTS<br>
191 	  if dptr or fit is NULL or dsz is 0,
192 	- DK4_E_MATH_OVERFLOW<br>
193 	  if a mathematical overflow occures in a size calculation,
194 	- DK4_E_BUFFER_TOO_SMALL<br>
195 	  if the buffer is too small,
196 	- DK4_E_BUG<br>
197 	  if CRT or Windows API functions failed to convert the timestamp to
198 	  local time information.
199 */
200 int
201 dk4filetime_to_text(
202   dkChar		*dptr,
203   size_t		 dsz,
204   const dk4_file_time_t	*fit,
205   dk4_er_t		*erp
206 );
207 
208 #ifdef __cplusplus
209 }
210 #endif
211 
212 
213 
214 
215 #endif
216