Use time_t rather than struct tm

weechat-hashes
C. McEnroe 2020-02-03 18:41:52 -05:00
parent c9470b59a1
commit 26e9dd9adf
3 changed files with 10 additions and 9 deletions

4
chat.h
View File

@ -115,9 +115,9 @@ void uiShow(void);
void uiHide(void); void uiHide(void);
void uiDraw(void); void uiDraw(void);
void uiShowID(size_t id); void uiShowID(size_t id);
void uiWrite(size_t id, enum Heat heat, const struct tm *time, const char *str); void uiWrite(size_t id, enum Heat heat, const time_t *time, const char *str);
void uiFormat( void uiFormat(
size_t id, enum Heat heat, const struct tm *time, const char *format, ... size_t id, enum Heat heat, const time_t *time, const char *format, ...
) __attribute__((format(printf, 4, 5))); ) __attribute__((format(printf, 4, 5)));
static inline enum Color hash(const char *str) { static inline enum Color hash(const char *str) {

View File

@ -71,12 +71,13 @@ static void require(struct Message *msg, bool origin, size_t len) {
} }
} }
static const struct tm *tagTime(const struct Message *msg) { static const time_t *tagTime(const struct Message *msg) {
static time_t time;
struct tm tm;
if (!msg->tags[TagTime]) return NULL; if (!msg->tags[TagTime]) return NULL;
static struct tm time; if (!strptime(msg->tags[TagTime], "%FT%T", &tm)) return NULL;
char *rest = strptime(msg->tags[TagTime], "%FT%T", &time); time = timegm(&tm);
time.tm_gmtoff = 0; return &time;
return (rest ? &time : NULL);
} }
typedef void Handler(struct Message *msg); typedef void Handler(struct Message *msg);

4
ui.c
View File

@ -372,7 +372,7 @@ void uiShowID(size_t id) {
statusUpdate(); statusUpdate();
} }
void uiWrite(size_t id, enum Heat heat, const struct tm *time, const char *str) { void uiWrite(size_t id, enum Heat heat, const time_t *time, const char *str) {
(void)time; (void)time;
struct Window *window = windowFor(id); struct Window *window = windowFor(id);
waddch(window->pad, '\n'); waddch(window->pad, '\n');
@ -387,7 +387,7 @@ void uiWrite(size_t id, enum Heat heat, const struct tm *time, const char *str)
} }
void uiFormat( void uiFormat(
size_t id, enum Heat heat, const struct tm *time, const char *format, ... size_t id, enum Heat heat, const time_t *time, const char *format, ...
) { ) {
char buf[1024]; char buf[1024];
va_list ap; va_list ap;