#include <derive-c/core/prelude.h>
#include <derive-c/core/debug/fmt.h>
#include <derive-c/test/mock.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>
Go to the source code of this file.
◆ DC_NS_PER_SEC
| #define DC_NS_PER_SEC 1000000000ULL |
◆ dc_timezone
◆ dc_datetime_debug()
Definition at line 80 of file timestamp.h.
80 {
81 fprintf(
stream,
"dc_datetime {\n");
83
92
95}
static DC_PUBLIC void dc_debug_fmt_print(dc_debug_fmt fmt, FILE *stream, const char *format,...)
static DC_PUBLIC dc_debug_fmt dc_debug_fmt_scope_end(dc_debug_fmt fmt)
static DC_PUBLIC dc_debug_fmt dc_debug_fmt_scope_begin(dc_debug_fmt fmt)
static DC_PUBLIC FILE * stream(SELF *self)
◆ dc_datetime_format()
Definition at line 66 of file timestamp.h.
66 {
67 char buf[32];
68 strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", &dt->tm);
69
70 char const* tz_suffix;
71 switch (dt->tz) {
73 tz_suffix = "Z";
74 break;
75 }
76
77 fprintf(
stream,
"%s.%09u%s", buf, dt->nanos, tz_suffix);
78}
◆ dc_datetime_from_timestamp()
Definition at line 32 of file timestamp.h.
32 {
35
39
40 switch (tz) {
42 gmtime_r(&secs, &dt.
tm);
43 break;
44 }
45
46 return dt;
47}
◆ dc_datetime_now_utc()
Definition at line 49 of file timestamp.h.
49 {
51}
static DC_PUBLIC dc_datetime dc_datetime_from_timestamp(dc_timestamp ts, dc_timezone tz)
◆ dc_datetime_to_timestamp()
Definition at line 53 of file timestamp.h.
53 {
54 struct tm tm_copy = dt->tm;
55 time_t secs;
56
57 switch (dt->tz) {
59 secs = timegm(&tm_copy);
60 break;
61 }
62
64}
◆ DC_MOCKABLE()
Definition at line 26 of file timestamp.h.
26 {
27 struct timespec ts;
28 clock_gettime(CLOCK_REALTIME, &ts);
30}