summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2019-12-05 15:07:51 +0100
committerJeremy Allison <jra@samba.org>2019-12-06 00:17:35 +0000
commit2e687d0e4dba9a0f94e532726e1f3dceaa3ed840 (patch)
treeecc0931ba56fa3c8dafefb827339a774e7cc2e60 /lib
parent6f9a824fdad1deb9e738850638328d04731b9d7a (diff)
downloadsamba-2e687d0e4dba9a0f94e532726e1f3dceaa3ed840.tar.gz
lib: add nt_time_to_full_time_t()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=7771 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/util/time.c17
-rw-r--r--lib/util/time.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/util/time.c b/lib/util/time.c
index 05918a94ea5..89f9a45dd61 100644
--- a/lib/util/time.c
+++ b/lib/util/time.c
@@ -1116,3 +1116,20 @@ time_t full_timespec_to_time_t(const struct timespec *_ts)
}
return ts.tv_sec;
}
+
+/**
+ * Like nt_time_to_unix() but supports negative time_t values.
+ *
+ * Note: this function uses the full time_t range as valid date values including
+ * (time_t)0 and -1. That means that NTTIME sentinel values of 0 and -1 which
+ * represent a "not-set" value, can't be converted to sentinel values in a
+ * time_t representation. Callers should therefor check the NTTIME value with
+ * null_nttime() before calling this function.
+ **/
+time_t nt_time_to_full_time_t(NTTIME nt)
+{
+ struct timespec ts;
+
+ ts = nt_time_to_full_timespec(nt);
+ return full_timespec_to_time_t(&ts);
+}
diff --git a/lib/util/time.h b/lib/util/time.h
index b9bd67499f6..725be9d8cec 100644
--- a/lib/util/time.h
+++ b/lib/util/time.h
@@ -344,5 +344,6 @@ struct timespec make_omit_timespec(void);
NTTIME full_timespec_to_nt_time(const struct timespec *ts);
struct timespec nt_time_to_full_timespec(NTTIME nt);
time_t full_timespec_to_time_t(const struct timespec *ts);
+time_t nt_time_to_full_time_t(NTTIME nt);
#endif /* _SAMBA_TIME_H_ */