summaryrefslogtreecommitdiffstats
path: root/util.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-02-13 16:30:05 -0500
committerTavian Barnes <tavianator@tavianator.com>2020-02-13 16:39:30 -0500
commit95f862fdd82a99e30bbf2c43009ec9a51e416804 (patch)
tree0edafaf7a69935d56dc4ce8b442325e12dfd88ff /util.h
parent2cdc648441794db0f84518f79e8aaf3ead68f110 (diff)
downloadbfs-95f862fdd82a99e30bbf2c43009ec9a51e416804.tar.xz
parse: Handle 1969-12-31T23:59:59Z
mktime() returns -1 on error, but also for one second before the epoch. Compare the input against localtime(-1) to distinguish those cases.
Diffstat (limited to 'util.h')
-rw-r--r--util.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/util.h b/util.h
index ef546d4..ae12703 100644
--- a/util.h
+++ b/util.h
@@ -182,14 +182,28 @@ int xlocaltime(const time_t *timep, struct tm *result);
int xgmtime(const time_t *timep, struct tm *result);
/**
+ * mktime() wrapper that reports errors more reliably.
+ *
+ * @param[in,out] tm
+ * The struct tm to convert.
+ * @param[out] timep
+ * Where to store the result.
+ * @return
+ * 0 on success, -1 on failure.
+ */
+int xmktime(struct tm *tm, time_t *timep);
+
+/**
* A portable timegm(), the inverse of gmtime().
*
- * @param tm
+ * @param[in,out] tm
* The struct tm to convert.
+ * @param[out] timep
+ * Where to store the result.
* @return
- * The converted time on success, or -1 on failure.
+ * 0 on success, -1 on failure.
*/
-time_t xtimegm(struct tm *tm);
+int xtimegm(struct tm *tm, time_t *timep);
/**
* Format a mode like ls -l (e.g. -rw-r--r--).