diff options
author | Ralph Boehme <slow@samba.org> | 2019-12-04 15:05:19 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-12-06 00:17:36 +0000 |
commit | 7a69f642d7b138255a73ef42ab6dd9a5e50e5309 (patch) | |
tree | 46129a15a7217f9a6f3a175644e4e4131ba7a788 /lib/util/time.c | |
parent | 928694af7e79edd0a48e43bb48af6fab9d32da89 (diff) | |
download | samba-7a69f642d7b138255a73ef42ab6dd9a5e50e5309.tar.gz |
lib: add time_t_to_full_timespec()
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/util/time.c')
-rw-r--r-- | lib/util/time.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/util/time.c b/lib/util/time.c index b69e2e02847..46d188eb897 100644 --- a/lib/util/time.c +++ b/lib/util/time.c @@ -1189,3 +1189,17 @@ time_t nt_time_to_full_time_t(NTTIME nt) ts = nt_time_to_full_timespec(nt); return full_timespec_to_time_t(&ts); } + +/** + * Like time_t_to_unix_timespec() but supports negative time_t values. + * + * This version converts (time_t)0 and -1 to an is_omit_timespec(), so 0 and -1 + * can't be used as valid date values. The function supports values < -1 though. + **/ +struct timespec time_t_to_full_timespec(time_t t) +{ + if (null_time(t)) { + return (struct timespec){.tv_nsec = SAMBA_UTIME_OMIT}; + } + return (struct timespec){.tv_sec = t}; +} |