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: dk4time08.ctr 12 */ 13 14 #ifndef DK4TIME08_H_INCLUDED 15 /** Avoid multiple inclusions. */ 16 #define DK4TIME08_H_INCLUDED 1 17 18 19 /** @file 20 Convert timestamp to char string, timestamp either given as set 21 of components (year, month, day, hour, minute, second), as 22 pointer to struct tm or as dk4_time_t value. 23 24 CRT on Windows: Optional. 25 */ 26 27 #ifndef DK4CONF_H_INCLUDED 28 #if DK4_BUILDING_DKTOOLS4 29 #include "dk4conf.h" 30 #else 31 #include <dktools-4/dk4conf.h> 32 #endif 33 #endif 34 35 #ifndef DK4TYPES_H_INCLUDED 36 #if DK4_BUILDING_DKTOOLS4 37 #include <libdk4base/dk4types.h> 38 #else 39 #include <dktools-4/dk4types.h> 40 #endif 41 #endif 42 43 #ifndef DK4ERROR_H_INCLUDED 44 #if DK4_BUILDING_DKTOOLS4 45 #include <libdk4base/dk4error.h> 46 #else 47 #include <dktools-4/dk4error.h> 48 #endif 49 #endif 50 51 #ifndef DK4TIME_H_INCLUDED 52 #if DK4_BUILDING_DKTOOLS4 53 #include <libdk4c/dk4time.h> 54 #else 55 #include <dktools-4/dk4time.h> 56 #endif 57 #endif 58 59 #ifndef DK4TIMEC_H_INCLUDED 60 #if DK4_BUILDING_DKTOOLS4 61 #include <libdk4c/dk4timec.h> 62 #else 63 #include <dktools-4/dk4timec.h> 64 #endif 65 #endif 66 67 #ifdef __cplusplus 68 extern "C" { 69 #endif 70 71 /** Convert timestamp to char string. 72 CRT on Windows: Optional. 73 @param dptr Destination buffer address. 74 @param dsz Destination buffer size (number of char). 75 @param format Output format: 76 DK4_TIMEFORMAT_DATE_TIME for sortable date/time 77 combination 78 yyyy-mm-dd hh:mm:ss 79 (default), 80 DK4_TIMEFORMAT_DATE_SORTABLE for sortable date 81 yyyy-mm-dd, 82 DK4_TIMEFORMAT_DATE_ENGLISH for English style date 83 mm/dd/yyyy, 84 DK4_TIMEFORMAT_DATE_GERMAN for German style date 85 dd.mm.yyyy. 86 @param year Year. 87 @param month Month (1 to 12). 88 @param mday Day within month (1 to 31). 89 @param hour Hour of day (0 to 23). 90 @param min Minute within hour (0 to 59). 91 @param sec Second within minute (0 to 59). 92 @param erp Error report, may be NULL. 93 @return 1 on success, 0 on error. 94 95 Error codes: 96 - DK4_E_INVALID_ARGUMENTS<br> 97 if dptr is NULL or dsz is 0, 98 - DK4_E_BUFFER_TOO_SMALL<br> 99 if the buffer is too small. 100 101 */ 102 int 103 dk4time_to_text_c8( 104 char *dptr, 105 size_t dsz, 106 int format, 107 unsigned short year, 108 unsigned short month, 109 unsigned short mday, 110 unsigned short hour, 111 unsigned short min, 112 unsigned short sec, 113 dk4_er_t *erp 114 ); 115 116 /** Create text representation for a struct tm. 117 CRT on Windows: Required. 118 @param dptr Destination buffer address. 119 @param dsz Destination buffer size (number of wchar_t). 120 @param tm Struct to convert. 121 @param erp Error report, may be NULL. 122 @return 1 on success, 0 on error. 123 124 Error codes: 125 - DK4_E_INVALID_ARGUMENTS<br> 126 if dptr is NULL or dsz is 0, 127 - DK4_E_BUFFER_TOO_SMALL<br> 128 if the buffer is too small. 129 */ 130 int 131 dk4time_convert_to_text_c8( 132 char *dptr, size_t dsz, const struct tm *tm, dk4_er_t *erp 133 ); 134 135 /** Create text representation for timestamp. 136 CRT on Windows: Required. 137 @param dptr Destination buffer address. 138 @param dsz Destination buffer size. 139 @param timer Timestamp to convert. 140 @param erp Error report, may be NULL. 141 @return 1 on success, 0 on error. 142 143 Error codes: 144 - DK4_E_INVALID_ARGUMENTS<br> 145 if dptr is NULL or dsz is 0, 146 - DK4_E_BUG<br> 147 if an internal conversion function fails, 148 - DK4_E_BUFFER_TOO_SMALL<br> 149 if the buffer is too small. 150 */ 151 int 152 dk4time_as_text_c8( 153 char *dptr, size_t dsz, const dk4_time_t *timer, dk4_er_t *erp 154 ); 155 156 #ifdef __cplusplus 157 } 158 #endif 159 160 161 #endif 162