X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Ftimestamp.h;h=406f6a5db7f34f929b4f6dc4492bef0556a96c78;hb=c9812a5d413382b81552979b10e5c478b3721316;hp=9c82c23e2081dab9d8f3212bfd6c8e5ba1286a92;hpb=7c08b0b067f48e80226e6b5466fd95feb43139e6;p=wimlib diff --git a/src/timestamp.h b/src/timestamp.h index 9c82c23e..406f6a5d 100644 --- a/src/timestamp.h +++ b/src/timestamp.h @@ -3,6 +3,8 @@ #include "util.h" #include +#include +#include #define intervals_per_second (1000000000ULL / 100ULL) #define intervals_per_microsecond (10) @@ -36,6 +38,13 @@ static inline u64 timeval_to_wim_timestamp(const struct timeval *tv) + (u64)tv->tv_usec * intervals_per_microsecond; } +static inline void wim_timestamp_to_timeval(u64 timestamp, struct timeval *tv) +{ + tv->tv_sec = (timestamp - intervals_1601_to_1970) / intervals_per_second; + tv->tv_usec = ((timestamp - intervals_1601_to_1970) / + intervals_per_microsecond) % 1000000; +} + static inline u64 timespec_to_wim_timestamp(const struct timespec *ts) { return intervals_1601_to_1970 @@ -44,5 +53,6 @@ static inline u64 timespec_to_wim_timestamp(const struct timespec *ts) } extern u64 get_wim_timestamp(); +extern void wim_timestamp_to_str(u64 timestamp, char *buf, size_t len); #endif