summaryrefslogtreecommitdiff
path: root/utils/time.h
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-04-16 23:27:38 +0100
committerVincent Sanders <vince@kyllikki.org>2016-04-16 23:50:22 +0100
commit0bc5d2ca4cee4e6ace987d424098d643e40f1ca1 (patch)
treeb17174ae68397f2791383cf7dc6755d4177fa462 /utils/time.h
parent33c7df0c40023cb1b0c17084680a21ee8e0229ea (diff)
downloadnetsurf-0bc5d2ca4cee4e6ace987d424098d643e40f1ca1.tar.gz
netsurf-0bc5d2ca4cee4e6ace987d424098d643e40f1ca1.tar.bz2
create date and time to seconds since epoch processing utility function
currently NetSurf uses curl_getdate to convert textural date and time strings into seconds since epoch. It is betetr to move this functionality to a utility function so curl_getdate can easily be replaced if required.
Diffstat (limited to 'utils/time.h')
-rw-r--r--utils/time.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/utils/time.h b/utils/time.h
index bde2ff66a..a99cdc24a 100644
--- a/utils/time.h
+++ b/utils/time.h
@@ -48,6 +48,28 @@ int nsc_sntimet(char *str, size_t size, time_t *timep);
* @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);
+nserror nsc_snptimet(const char *str, size_t size, time_t *timep);
+
+
+/**
+ * Converts a date string to a number of seconds since epoch
+ *
+ * returns the number of seconds since the Epoch, January 1st 1970
+ * 00:00:00 in the UTC time zone, for the date and time that the
+ * \a str parameter specifies.
+ *
+ * datetime strings passed must be in one of the formats specified in:
+ * - RFC 822 (updated in RFC 1123) using time zone name or time zone delta
+ * - RFC 850 (obsoleted by RFC 1036)
+ * - ANSI C's asctime() format.
+ *
+ * @param[in] str The datetime string to parse
+ * @param[in] size The length of the source string
+ * @param[out] timep Pointer to result on success unmodified on error.
+ * @return NSERROR_OK on success and timep updated else
+ * NSERROR_INVALID if the string parsing failed otherwise a suitable
+ * error code
+ */
+nserror nsc_strntimet(const char *str, size_t size, time_t *timep);
#endif