1%%	options
2
3copyright owner	=	Dirk Krause
4copyright year	=	2015-xxxx
5SPDX-License-Identifier:	BSD-3-Clause
6
7
8
9%%	module
10
11#include "dk4conf.h"
12
13#if	DK4_HAVE_ASSERT_H
14#ifndef	ASSERT_H_INCLUDED
15#include <assert.h>
16#define	ASSERT_H_INCLUDED 1
17#endif
18#endif
19
20#include <libdk4c/dk4ftime.h>
21
22#ifndef DK4TIME08_H_INCLUDED
23#include <libdk4c/dk4time08.h>
24#endif
25
26
27
28int
29dk4filetime_to_text_c8(
30  char			*dptr,
31  size_t		 dsz,
32  const dk4_file_time_t	*fit,
33  dk4_er_t		*erp
34)
35{
36#if DK4_ON_WINDOWS
37  SYSTEMTIME	 st1;
38  SYSTEMTIME	 st2;
39  int		 back = 0;
40#if	DK4_USE_ASSERT
41  assert(NULL != dptr);
42  assert(0 < dsz);
43  assert(NULL != fit);
44#endif
45  if ((NULL != dptr) && (NULL != fit) && (0 < dsz)) {
46    if (FileTimeToSystemTime(fit, &st1)) {
47      if (SystemTimeToTzSpecificLocalTime(NULL, &st1, &st2)) {
48        back = dk4time_to_text_c8(
49	  dptr, dsz, DK4_TIMEFORMAT_DATE_TIME,
50	  st2.wYear, st2.wMonth, st2.wDay,
51	  st2.wHour, st2.wMinute, st2.wSecond,
52	  erp
53	);
54      } else {
55        /* Error: Conversion to local time failed */
56	dk4error_set_simple_error_code(erp, DK4_E_BUG);
57      }
58    } else {
59      /* Error: Time conversion failed */
60      dk4error_set_simple_error_code(erp, DK4_E_BUG);
61    }
62  } else {
63    dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS);
64  }
65  return back;
66#else
67#if	DK4_USE_ASSERT
68  assert(NULL != dptr);
69  assert(0 < dsz);
70  assert(NULL != fit);
71#endif
72  return (dk4time_as_text_c8(dptr, dsz, fit, erp));
73#endif
74}
75
76