s3:lib: add put_long_date_full_timespec()
[vlendec/samba-autobuild/.git] / source3 / lib / time.c
index 00cf0f16c1f1daa0453d3cf641e4680f08754564..a5882f3d8ff5db0b84f44cdf712c3c9a9ad867b4 100644 (file)
 #define TIME_FIXUP_CONSTANT_INT 11644473600LL
 #endif
 
-
-/**
-  parse a nttime as a large integer in a string and return a NTTIME
-*/
-NTTIME nttime_from_string(const char *s)
-{
-       return strtoull(s, NULL, 0);
-}
-
 /**************************************************************
  Handle conversions between time_t and uint32, taking care to
  preserve the "special" values.
@@ -150,6 +141,10 @@ void srv_put_dos_date3(char *buf,int offset,time_t unixdate)
 
 void round_timespec(enum timestamp_set_resolution res, struct timespec *ts)
 {
+       if (is_omit_timespec(ts)) {
+               return;
+       }
+
        switch (res) {
                case TIMESTAMP_SET_SECONDS:
                        round_timespec_to_sec(ts);
@@ -172,9 +167,20 @@ void put_long_date_timespec(enum timestamp_set_resolution res, char *p, struct t
 {
        NTTIME nt;
        round_timespec(res, &ts);
-       unix_timespec_to_nt_time(&nt, ts);
-       SIVAL(p, 0, nt & 0xFFFFFFFF);
-       SIVAL(p, 4, nt >> 32);
+       nt = unix_timespec_to_nt_time(ts);
+       SBVAL(p, 0, nt);
+}
+
+void put_long_date_full_timespec(enum timestamp_set_resolution res,
+                                char *p,
+                                const struct timespec *_ts)
+{
+       struct timespec ts = *_ts;
+       NTTIME nt;
+
+       round_timespec(res, &ts);
+       nt = full_timespec_to_nt_time(&ts);
+       SBVAL(p, 0, nt);
 }
 
 void put_long_date(char *p, time_t t)
@@ -244,14 +250,14 @@ time_t srv_make_unix_date3(const void *date_ptr)
 struct timespec interpret_long_date(const char *p)
 {
        NTTIME nt;
-       nt = IVAL(p,0) + ((uint64_t)IVAL(p,4) << 32);
+       nt = BVAL(p, 0);
        if (nt == (uint64_t)-1) {
                struct timespec ret;
                ret.tv_sec = (time_t)-1;
                ret.tv_nsec = 0;
                return ret;
        }
-       return nt_time_to_unix_timespec(&nt);
+       return nt_time_to_unix_timespec(nt);
 }
 
 /*******************************************************************
@@ -344,13 +350,6 @@ time_t nt_time_to_unix_abs(const NTTIME *nt)
        return (time_t)d;
 }
 
-time_t uint64s_nt_time_to_unix_abs(const uint64_t *src)
-{
-       NTTIME nttime;
-       nttime = *src;
-       return nt_time_to_unix_abs(&nttime);
-}
-
 /****************************************************************************
  Convert a time_t to a NTTIME structure