diff options
| author | 2022-10-02 09:27:17 +0200 | |
|---|---|---|
| committer | 2022-10-02 09:27:17 +0200 | |
| commit | 849913dc5987997f9db96e23c7acf9c29f9c6d7f (patch) | |
| tree | 142b0f98c094b4714b49562f90c952abb3e1f233 /snac.c | |
| parent | Backport from xs. (diff) | |
| download | penes-snac2-849913dc5987997f9db96e23c7acf9c29f9c6d7f.tar.gz penes-snac2-849913dc5987997f9db96e23c7acf9c29f9c6d7f.tar.xz penes-snac2-849913dc5987997f9db96e23c7acf9c29f9c6d7f.zip | |
Use the time functions of xs_time.h.
Diffstat (limited to '')
| -rw-r--r-- | snac.c | 21 |
1 files changed, 2 insertions, 19 deletions
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "xs_mime.h" | 14 | #include "xs_mime.h" |
| 15 | #include "xs_regex.h" | 15 | #include "xs_regex.h" |
| 16 | #include "xs_set.h" | 16 | #include "xs_set.h" |
| 17 | #include "xs_time.h" | ||
| 17 | 18 | ||
| 18 | #include "snac.h" | 19 | #include "snac.h" |
| 19 | 20 | ||
| @@ -28,24 +29,6 @@ int srv_running = 0; | |||
| 28 | int dbglevel = 0; | 29 | int dbglevel = 0; |
| 29 | 30 | ||
| 30 | 31 | ||
| 31 | d_char *xs_time(char *fmt, int local) | ||
| 32 | /* returns a d_char with a formated time */ | ||
| 33 | { | ||
| 34 | time_t t = time(NULL); | ||
| 35 | struct tm tm; | ||
| 36 | char tmp[64]; | ||
| 37 | |||
| 38 | if (local) | ||
| 39 | localtime_r(&t, &tm); | ||
| 40 | else | ||
| 41 | gmtime_r(&t, &tm); | ||
| 42 | |||
| 43 | strftime(tmp, sizeof(tmp), fmt, &tm); | ||
| 44 | |||
| 45 | return xs_str_new(tmp); | ||
| 46 | } | ||
| 47 | |||
| 48 | |||
| 49 | d_char *tid(int offset) | 32 | d_char *tid(int offset) |
| 50 | /* returns a time-based Id */ | 33 | /* returns a time-based Id */ |
| 51 | { | 34 | { |
| @@ -92,7 +75,7 @@ void srv_debug(int level, d_char *str) | |||
| 92 | } | 75 | } |
| 93 | 76 | ||
| 94 | if (dbglevel >= level) { | 77 | if (dbglevel >= level) { |
| 95 | xs *tm = xs_local_time("%H:%M:%S"); | 78 | xs *tm = xs_str_localtime(0, "%H:%M:%S"); |
| 96 | fprintf(stderr, "%s %s\n", tm, msg); | 79 | fprintf(stderr, "%s %s\n", tm, msg); |
| 97 | } | 80 | } |
| 98 | } | 81 | } |