aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.c
diff options
context:
space:
mode:
authorFrederic Culot <calcurse@culot.org>2008-08-10 09:24:46 +0000
committerFrederic Culot <calcurse@culot.org>2008-08-10 09:24:46 +0000
commit1674800d5fb26decfa74cb7a1d94e2154b7c27a6 (patch)
tree1e7b15d77ed74c2c150c9a1dc05cd709bba3ac81 /src/utils.c
parentcc3b4303056d891c4782469be50be21ca50e2271 (diff)
downloadcalcurse-1674800d5fb26decfa74cb7a1d94e2154b7c27a6.tar.gz
calcurse-1674800d5fb26decfa74cb7a1d94e2154b7c27a6.zip
pcal export added
Diffstat (limited to 'src/utils.c')
-rwxr-xr-xsrc/utils.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/utils.c b/src/utils.c
index 0263482..dadd52a 100755
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,4 +1,4 @@
-/* $calcurse: utils.c,v 1.46 2008/08/03 18:41:55 culot Exp $ */
+/* $calcurse: utils.c,v 1.47 2008/08/10 09:24:46 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -591,6 +591,44 @@ date_sec2ical_datetime (long sec, char *ical_datetime)
strftime (ical_datetime, DATETIMELENGTH, "%Y%m%dT%H%M%S", lt);
}
+/*
+ * At least a generic function to format date...
+ * I promise I will learn how to code someday.
+ */
+void
+date_sec2date_fmt (long sec, const char *fmt, char *datef)
+{
+ struct tm *lt;
+ time_t t;
+
+ t = sec;
+ lt = localtime (&t);
+ strftime (datef, BUFSIZ, fmt, lt);
+}
+
+/*
+ * Used to change date by adding a certain amount of days or weeks.
+ */
+long
+date_sec_change (long date, int delta_month, int delta_day)
+{
+ struct tm *lt;
+ time_t t;
+
+ t = date;
+ lt = localtime (&t);
+ lt->tm_mon += delta_month;
+ lt->tm_mday += delta_day;
+ t = mktime (lt);
+ if (t == -1)
+ {
+ fputs (_("FATAL ERROR in date_sec_change: failure in mktime\n"), stderr);
+ exit (EXIT_FAILURE);
+ }
+
+ return t;
+}
+
/*
* Return a long containing the date which is updated taking into account
* the new time and date entered by the user.