diff options
author | Sage Weil <sage@newdream.net> | 2012-03-27 10:41:54 -0700 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2012-03-27 10:41:54 -0700 |
commit | f66e0750e9c500f0405fbafb3974b6106600a6c6 (patch) | |
tree | d994d93af17cff6bdfe072e201c93221ddfbca63 /src/include | |
parent | 6ab8526438f45def1313182d38382c50f5ccbd04 (diff) | |
download | ceph-f66e0750e9c500f0405fbafb3974b6106600a6c6.tar.gz |
utime_t: sprintf() method
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/utime.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/include/utime.h b/src/include/utime.h index 943826791e5..6953a9bcf63 100644 --- a/src/include/utime.h +++ b/src/include/utime.h @@ -162,6 +162,17 @@ public: out.unsetf(std::ios::right); return out; } + + int sprintf(char *out, int outlen) const { + struct tm bdt; + time_t tt = sec(); + localtime_r(&tt, &bdt); + + return snprintf(out, outlen, + "%04d-%02d-%02d %02d:%02d:%02d.%06ld", + bdt.tm_year + 1900, bdt.tm_mon + 1, bdt.tm_mday, + bdt.tm_hour, bdt.tm_min, bdt.tm_sec, usec()); + } }; WRITE_CLASS_ENCODER(utime_t) |