summaryrefslogtreecommitdiff
path: root/utils/time.h
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-05-15 01:18:52 +0100
committerVincent Sanders <vince@kyllikki.org>2014-05-15 01:18:52 +0100
commitef00272e2ffb8ffcf03e740f74691fecb682060d (patch)
treed1ba29cf118a7f4c905762813d3985131fbacd34 /utils/time.h
parenta4be7f7d1abe5b75d3dacfbf00adf3bd937bc4c1 (diff)
downloadnetsurf-ef00272e2ffb8ffcf03e740f74691fecb682060d.tar.gz
netsurf-ef00272e2ffb8ffcf03e740f74691fecb682060d.tar.bz2
add helpers for time_t reading/writing
Diffstat (limited to 'utils/time.h')
-rw-r--r--utils/time.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/utils/time.h b/utils/time.h
new file mode 100644
index 000000000..bde2ff66a
--- /dev/null
+++ b/utils/time.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2014 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file utils/time.h
+ * \brief Interface to time operations.
+ */
+
+#ifndef _NETSURF_UTILS_TIME_H_
+#define _NETSURF_UTILS_TIME_H_
+
+#include <time.h>
+
+/**
+ * Write the time in seconds since epoch to a buffer.
+ *
+ * This is provided as strftime is not generally portable.
+ *
+ * @param str The destination buffer.
+ * @param size The length of the destination buffer.
+ * @param timep The pointer to the time to write.
+ * @return The length of the string written.
+ */
+int nsc_sntimet(char *str, size_t size, time_t *timep);
+
+/**
+ * Parse time in seconds since epoc.
+ *
+ * This is provided as strptime is not generally portable.
+ *
+ * @param str The source buffer.
+ * @param size The length of the source buffer.
+ * @param timep Pointer to result.
+ * @return NSERROR_OK on success or error code on faliure.
+ */
+nserror nsc_snptimet(char *str, size_t size, time_t *timep);
+
+#endif