diary

Text-based journaling program
git clone https://git.in0rdr.ch/diary.git
Log | Files | Refs | README | LICENSE

commit b574de537cb5f2bd3ae066ad8e637b465281a4e5
parent bb1b7be5044bd7aee34f59765332cc1b07ea2f7b
Author: Andreas Gruhler <agruhl@gmx.ch>
Date:   Fri, 21 May 2021 17:51:11 +0200

replace get_date_str with strftime

Diffstat:
Mdiary.c | 8++++----
Mutils.c | 5-----
Mutils.h | 2--
3 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/diary.c b/diary.c @@ -85,7 +85,7 @@ void update_date(WINDOW* header) { char dstr[16]; mktime(&curs_date); - get_date_str(&curs_date, dstr, sizeof dstr, CONFIG.fmt); + strftime(dstr, sizeof dstr, CONFIG.fmt, &curs_date); wclear(header); mvwaddstr(header, 0, 0, dstr); @@ -228,7 +228,7 @@ void fpath(const char* dir, size_t dir_size, const struct tm* date, char** rpath } char dstr[16]; - get_date_str(date, dstr, sizeof dstr, CONFIG.fmt); + strftime(dstr, sizeof dstr, CONFIG.fmt, date); // append date to the result path if (strlen(*rpath) + strlen(dstr) > rpath_size) { @@ -656,7 +656,7 @@ int main(int argc, char** argv) { noecho(); // ask for confirmation - get_date_str(&curs_date, dstr, sizeof dstr, CONFIG.fmt); + strftime(dstr, sizeof dstr, CONFIG.fmt, &curs_date); mvwprintw(header, 0, 0, "Delete entry '%s'? [Y/n] ", dstr); bool conf = false; while (!conf) { @@ -713,7 +713,7 @@ int main(int argc, char** argv) { break; // Sync with CalDAV server case 's': - //get_date_str(&curs_date, dstr, sizeof dstr, CONFIG.fmt); + //strftime(dstr, sizeof dstr, CONFIG.fmt, &curs_date); mktime(&curs_date); caldav_sync(&curs_date, header); break; diff --git a/utils.c b/utils.c @@ -58,8 +58,3 @@ config CONFIG = { .google_secretid = GOOGLE_OAUTH_CLIENT_SECRET, .google_calendar = "" }; - -void get_date_str(const struct tm* date, char* date_str, size_t date_str_size, const char* fmt) -{ - strftime(date_str, date_str_size, fmt, date); -} diff --git a/utils.h b/utils.h @@ -43,6 +43,4 @@ typedef struct config CONFIG; -void get_date_str(const struct tm* date, char* date_str, size_t date_str_size, const char* fmt); - #endif