summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2017-10-12 14:36:48 +0200
committerJohannes Berg <johannes.berg@intel.com>2017-10-13 10:57:21 +0200
commit245baebd9d4fda2cc824781298863aafb32eef89 (patch)
treecc6038d2f8c0753602405815d49727e871e50e69
parentbafd9393f7f77632ca883bc09ef296549a39a96d (diff)
backports: add mktime64()
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--backport/backport-include/linux/time64.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/backport/backport-include/linux/time64.h b/backport/backport-include/linux/time64.h
index 609b8904..49805da9 100644
--- a/backport/backport-include/linux/time64.h
+++ b/backport/backport-include/linux/time64.h
@@ -21,4 +21,26 @@
#define timespec64 timespec
#endif /* LINUX_VERSION_IS_LESS(3,17,0) */
+#if LINUX_VERSION_IS_LESS(3,19,0)
+static inline time64_t mktime64(const unsigned int year0, const unsigned int mon0,
+ const unsigned int day, const unsigned int hour,
+ const unsigned int min, const unsigned int sec)
+{
+ unsigned int mon = mon0, year = year0;
+
+ /* 1..12 -> 11,12,1..10 */
+ if (0 >= (int) (mon -= 2)) {
+ mon += 12; /* Puts Feb last since it has leap day */
+ year -= 1;
+ }
+
+ return ((((time64_t)
+ (year/4 - year/100 + year/400 + 367*mon/12 + day) +
+ year*365 - 719499
+ )*24 + hour /* now have hours - midnight tomorrow handled here */
+ )*60 + min /* now have minutes */
+ )*60 + sec; /* finally seconds */
+}
+#endif
+
#endif /* __BACKPORT_LINUX_TIME64_H */