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: dk4ftime08.ctr
12 */
13
14 /** @file dk4ftime08.c The dk4ftime08 module.
15 */
16
17
18 #include "dk4conf.h"
19
20 #if DK4_HAVE_ASSERT_H
21 #ifndef ASSERT_H_INCLUDED
22 #include <assert.h>
23 #define ASSERT_H_INCLUDED 1
24 #endif
25 #endif
26
27 #include <libdk4c/dk4ftime.h>
28
29 #ifndef DK4TIME08_H_INCLUDED
30 #include <libdk4c/dk4time08.h>
31 #endif
32
33
34
35 int
dk4filetime_to_text_c8(char * dptr,size_t dsz,const dk4_file_time_t * fit,dk4_er_t * erp)36 dk4filetime_to_text_c8(
37 char *dptr,
38 size_t dsz,
39 const dk4_file_time_t *fit,
40 dk4_er_t *erp
41 )
42 {
43 #if DK4_ON_WINDOWS
44 SYSTEMTIME st1;
45 SYSTEMTIME st2;
46 int back = 0;
47 #if DK4_USE_ASSERT
48 assert(NULL != dptr);
49 assert(0 < dsz);
50 assert(NULL != fit);
51 #endif
52 if ((NULL != dptr) && (NULL != fit) && (0 < dsz)) {
53 if (FileTimeToSystemTime(fit, &st1)) {
54 if (SystemTimeToTzSpecificLocalTime(NULL, &st1, &st2)) {
55 back = dk4time_to_text_c8(
56 dptr, dsz, DK4_TIMEFORMAT_DATE_TIME,
57 st2.wYear, st2.wMonth, st2.wDay,
58 st2.wHour, st2.wMinute, st2.wSecond,
59 erp
60 );
61 } else {
62 /* Error: Conversion to local time failed */
63 dk4error_set_simple_error_code(erp, DK4_E_BUG);
64 }
65 } else {
66 /* Error: Time conversion failed */
67 dk4error_set_simple_error_code(erp, DK4_E_BUG);
68 }
69 } else {
70 dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS);
71 }
72 return back;
73 #else
74 #if DK4_USE_ASSERT
75 assert(NULL != dptr);
76 assert(0 < dsz);
77 assert(NULL != fit);
78 #endif
79 return (dk4time_as_text_c8(dptr, dsz, fit, erp));
80 #endif
81 }
82
83