src/timestamp.h
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Thu, 04 Jun 2020 11:18:45 +0200
changeset 4729 3df9a2a67597
parent 4550 874a85ee3e59
child 4792 7056435ab9e7
child 4900 9066ebde8aa4
permissions -rw-r--r--
forgot test files
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 #pragma once
     5 
     6 #include <time.h>
     7 #include "dynamic_api.h"
     8 
     9 #ifdef __cplusplus
    10 extern "C" {
    11 #endif
    12 
    13 
    14 #ifdef WIN32
    15 // this struct is compatible to struct tm
    16 typedef struct _timestamp {
    17     int tm_sec;
    18     int tm_min;
    19     int tm_hour;
    20     int tm_mday;
    21     int tm_mon;
    22     int tm_year;
    23     int tm_wday;
    24     int tm_yday;
    25     int tm_isdst;
    26     long tm_gmtoff; // offset from GMT in seconds
    27 } timestamp;
    28 #else
    29 // for time values all functions are using POSIX struct tm
    30 typedef struct tm timestamp;
    31 #endif
    32 
    33 // new_timestamp() - allocate a new timestamp
    34 //
    35 //  parameters:
    36 //      clock (in)      initial value or 0 if not available
    37 //
    38 //  return value:
    39 //      pointer to timestamp object or NULL if out of memory
    40 
    41 DYNAMIC_API timestamp * new_timestamp(time_t clock);
    42 
    43 
    44 // free_timestamp() - free memory occupied by timestamp
    45 //
    46 //  parameters:
    47 //      ts (in)         pointer to timestamp to free
    48 
    49 DYNAMIC_API void free_timestamp(timestamp *ts);
    50 
    51 
    52 // timestamp_dup() - duplicate a timestamp
    53 //
    54 //  parameters:
    55 //      src (in)        pointer to timestamp to duplicate
    56 //
    57 //  return value:
    58 //      pointer to copy or NULL if out of memory
    59 
    60 DYNAMIC_API timestamp * timestamp_dup(const timestamp *src);
    61 
    62 
    63 #ifdef __cplusplus
    64 }
    65 #endif
    66