aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/calcurse.h2
-rw-r--r--src/strings.c20
2 files changed, 22 insertions, 0 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index 8bcb48a..4ddb066 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -1028,6 +1028,8 @@ char *string_buf(struct string *);
int string_catf(struct string *, const char *, ...);
int string_vcatf(struct string *, const char *, va_list);
int string_printf(struct string *, const char *, ...);
+int string_catftime(struct string *, const char *, const struct tm *);
+int string_strftime(struct string *, const char *, const struct tm *);
/* todo.c */
extern llist_t todolist;
diff --git a/src/strings.c b/src/strings.c
index 816ddc1..6601a99 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -112,3 +112,23 @@ int string_printf(struct string *sb, const char *format, ...)
return n;
}
+
+int string_catftime(struct string *sb, const char *format, const struct tm *tm)
+{
+ int n = 0;
+
+ while (!n) {
+ string_grow(sb, sb->bufsize * 2);
+ n = strftime(sb->buf + sb->len, sb->bufsize - sb->len, format,
+ tm);
+ }
+ sb->len += n;
+
+ return n;
+}
+
+int string_strftime(struct string *sb, const char *format, const struct tm *tm)
+{
+ string_reset(sb);
+ return string_catftime(sb, format, tm);
+}