Hash :
6ed7c240
Author :
Thomas de Grivel
Date :
2025-08-02T13:12:29
vibe coding kc3_uptime and time_diff_to_str and kc3 wrappers for those two functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
/* kc3
* Copyright from 2022 to 2025 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software granted the above
* copyright notice and this permission paragraph are included in all
* copies and substantial portions of this software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
/**
* @file time.h
* @brief operations on s_timespec
*
*/
#ifndef LIBKC3_TIME_H
#define LIBKC3_TIME_H
#include "types.h"
#ifdef WIN32
#define timegm _mkgmtime
#endif
#define TIME_SECONDS_PER_MINUTE (60)
#define TIME_SECONDS_PER_HOUR (60 * 60)
#define TIME_SECONDS_PER_DAY (60 * 60 * 24)
#define TIME_SECONDS_PER_MONTH (60 * 60 * 24 * 31)
/* Stack-allocation compatible functions. Call time_clean if
time_init argument allocate was true. */
void time_clean (s_time *time);
s_time * time_init (s_time *time);
s_time * time_init_add (s_time *time, const s_time *a, const s_time *b);
s_time * time_init_cast (s_time *time, const s_sym * const *type,
const s_tag *src);
s_time * time_init_copy (s_time *time, const s_time *src);
s_time * time_init_now (s_time *time);
s_time * time_init_str (s_time *time, const s_str *src);
/* Observers */
s_tag * time_access (s_time *time, s_list *key, s_tag *dest);
s_str * time_diff_to_str (const s_time *time, s_str *dest);
s_str * time_to_str (const s_time *time, s_str *dest);
/* Operators */
s_time * time_allocate (s_time *time);
s_time * time_sub (const s_time *a, const s_time *b,
s_time *dest);
s_timespec * timespec_sub (const s_timespec *a, const s_timespec *b,
s_timespec *dest);
f64 * timespec_to_f64 (const s_timespec *time, f64 *dest);
s_tag * timespec_to_tag (const s_timespec *time, s_tag *dest);
#endif /* LIBKC3_TIME_H */