]> Dogcows Code - chaz/tar/blobdiff - src/misc.c
Don't filter time stamps through the resolution supported
[chaz/tar] / src / misc.c
index 55bedd2b2c901669ff4025feadbb2fd338984831..7322dd2a0f56c89cde3db3d24c14c51bb4ad1a4a 100644 (file)
@@ -239,6 +239,27 @@ code_ns_fraction (int ns, char *p)
        }
     }
 }
+
+char const *
+code_timespec (struct timespec t, char sbuf[TIMESPEC_STRSIZE_BOUND])
+{
+  time_t s = t.tv_sec;
+  int ns = t.tv_nsec;
+  char *np;
+  bool negative = s < 0;
+
+  if (negative && ns != 0)
+    {
+      s++;
+      ns = BILLION - ns;
+    }
+
+  np = umaxtostr (negative ? - (uintmax_t) s : (uintmax_t) s, sbuf + 1);
+  if (negative)
+    *--np = '-';
+  code_ns_fraction (ns, sbuf + UINTMAX_STRSIZE_BOUND);
+  return np;
+}
 \f
 /* File handling.  */
 
This page took 0.022484 seconds and 4 git commands to generate.