about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-03 18:41:52 -0500
committerJune McEnroe <june@causal.agency>2020-02-03 18:41:52 -0500
commit26e9dd9adfd4df90cd4cc6ef14d91cdad2efb239 (patch)
tree6c4a44b69dae6be1fa75395fe23cd735669c5462
parentAdd sequences for toggling focus/paste modes (diff)
downloadcatgirl-26e9dd9adfd4df90cd4cc6ef14d91cdad2efb239.tar.gz
catgirl-26e9dd9adfd4df90cd4cc6ef14d91cdad2efb239.zip
Use time_t rather than struct tm
Diffstat (limited to '')
-rw-r--r--chat.h4
-rw-r--r--handle.c11
-rw-r--r--ui.c4
3 files changed, 10 insertions, 9 deletions
diff --git a/chat.h b/chat.h
index 76d69c9..9165c13 100644
--- a/chat.h
+++ b/chat.h
@@ -115,9 +115,9 @@ void uiShow(void);
 void uiHide(void);
 void uiDraw(void);
 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(
-	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)));
 
 static inline enum Color hash(const char *str) {
diff --git a/handle.c b/handle.c
index 4bc2e3d..ef49f7c 100644
--- a/handle.c
+++ b/handle.c
@@ -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;
-	static struct tm time;
-	char *rest = strptime(msg->tags[TagTime], "%FT%T", &time);
-	time.tm_gmtoff = 0;
-	return (rest ? &time : NULL);
+	if (!strptime(msg->tags[TagTime], "%FT%T", &tm)) return NULL;
+	time = timegm(&tm);
+	return &time;
 }
 
 typedef void Handler(struct Message *msg);
diff --git a/ui.c b/ui.c
index 072ee84..e2746f1 100644
--- a/ui.c
+++ b/ui.c
@@ -372,7 +372,7 @@ void uiShowID(size_t id) {
 	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;
 	struct Window *window = windowFor(id);
 	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(
-	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];
 	va_list ap;