commit 3202b728c6401e95389d08217417588d462676f7
parent 8599ae0d6d889e49d9a51569f51154cde9169347
Author: Andreas Gruhler <agruhl@gmx.ch>
Date: Wed, 2 Jun 2021 22:21:55 +0200
move update_date() to utils
Diffstat:
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/utils.c b/utils.c
@@ -1,5 +1,18 @@
#include "utils.h"
+/* Update the header with the cursor date */
+void update_date(WINDOW* header, struct tm* curs_date) {
+ // TODO: dstr for strlen(CONFIG.format) > 16 ?
+ char dstr[16];
+ mktime(curs_date);
+ strftime(dstr, sizeof dstr, CONFIG.fmt, curs_date);
+
+ wclear(header);
+ mvwaddstr(header, 0, 0, dstr);
+ wrefresh(header);
+}
+
+
char* extract_json_value(const char* json, char* key, bool quoted) {
// work on a copy of the json
char* jsoncp = (char*) malloc(strlen(json) * sizeof(char));
diff --git a/utils.h b/utils.h
@@ -8,6 +8,7 @@
#include <string.h>
#include <wordexp.h>
#include <stdbool.h>
+#include <ncurses.h>
#define GOOGLE_OAUTH_TOKEN_FILE "~/.diary-token"
#ifndef GOOGLE_OAUTH_CLIENT_ID
@@ -21,6 +22,7 @@
#define ASIDE_WIDTH 4
#define MAX_MONTH_HEIGHT 6
+void update_date(WINDOW* header, struct tm* curs_date);
char* extract_json_value(const char* json, char* key, bool quoted);
char* extract_ical_field(const char* ical, char* key, bool multline);
char* expand_path(const char* str);