1%% options 2 3copyright owner = Dirk Krause 4copyright year = 2015-xxxx 5SPDX-License-Identifier: BSD-3-Clause 6 7 8 9%% header 10 11/** @file 12 Retrieve current timestamp using CRT functions. 13 14 15 CRT on Windows: Required. 16*/ 17 18#ifndef DK4CONF_H_INCLUDED 19#if DK4_BUILDING_DKTOOLS4 20#include "dk4conf.h" 21#else 22#include <dktools-4/dk4conf.h> 23#endif 24#endif 25 26#ifndef DK4TYPES_H_INCLUDED 27#if DK4_BUILDING_DKTOOLS4 28#include <libdk4base/dk4types.h> 29#else 30#include <dktools-4/dk4types.h> 31#endif 32#endif 33 34#ifndef DK4ERROR_H_INCLUDED 35#if DK4_BUILDING_DKTOOLS4 36#include <libdk4base/dk4error.h> 37#else 38#include <dktools-4/dk4error.h> 39#endif 40#endif 41 42#if DK4_TIME_WITH_SYS_TIME 43#ifndef SYS_TIME_H_INCLUDED 44#include <sys/time.h> 45#define SYS_TIME_H_INCLUDED 1 46#endif 47#ifndef TIME_H_INCLUDED 48#include <time.h> 49#define TIME_H_INCLUDED 1 50#endif 51#else 52#if DK4_HAVE_TIME_H 53#ifndef TIME_H_INCLUDED 54#include <time.h> 55#define TIME_H_INCLUDED 1 56#endif 57#else 58#if DK4_HAVE_SYS_TIME_H 59#ifndef SYS_TIME_H_INCLUDED 60#include <sys/time.h> 61#define SYS_TIME_H_INCLUDED 1 62#endif 63#endif 64#endif 65#endif 66 67 68#if DK4_ON_WINDOWS 69/** Timestamp. 70*/ 71typedef __time64_t dk4_time_t; 72#else 73/** Timestamp. 74*/ 75typedef time_t dk4_time_t; 76#endif 77 78#ifdef __cplusplus 79extern "C" { 80#endif 81 82/** Retrieve current time. 83 @param timer Address of result variable. 84*/ 85void 86dk4time_get(dk4_time_t *timer); 87 88#ifdef __cplusplus 89} 90#endif 91 92%% module 93 94#include "dk4conf.h" 95 96#if DK4_HAVE_ASSERT_H 97#ifndef ASSERT_H_INCLUDED 98#include <assert.h> 99#define ASSERT_H_INCLUDED 1 100#endif 101#endif 102 103#include <libdk4c/dk4time.h> 104 105 106 107#if 0 108static const char * const dk4time_kw[] = { 109/* 0 */ "0", 110/* 1 */ " ", 111/* 2 */ "-", 112/* 3 */ ":" 113}; 114#endif 115 116 117 118void 119dk4time_get(dk4_time_t *timer) 120{ 121#if DK4_USE_ASSERT 122 assert(NULL != timer); 123#endif 124#if DK4_ON_WINDOWS 125 (void)_time64(timer); 126#else 127 (void)time(timer); 128#endif 129} 130 131 132 133