X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=util.h;h=0d1b45d45e83983bf62194a5d631d3f41eeacb20;hb=262f66f165516f2ae3923b708d860a8711fc7c58;hp=38596b5fcbb028d1e023b7534d4264380450f188;hpb=974240b635af9cf2b94e2f1f3c02beab662a189d;p=cumulus.git diff --git a/util.h b/util.h index 38596b5..0d1b45d 100644 --- a/util.h +++ b/util.h @@ -1,7 +1,6 @@ -/* Cumulus: Smart Filesystem Backup to Dumb Servers - * - * Copyright (C) 2007 The Regents of the University of California - * Written by Michael Vrable +/* Cumulus: Efficient Filesystem Backup to the Cloud + * Copyright (C) 2007 The Cumulus Developers + * See the AUTHORS file for a list of contributors. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,4 +36,25 @@ void cloexec(int fd); void fatal(std::string msg) __attribute__((noreturn)); +/* Date/time string formatting and parsing utility functions. All data and + * methods are static, so this class should not be instantiated. */ +class TimeFormat { +public: + // Abbreviated time format encoded in snapshot file names. + static const char FORMAT_FILENAME[]; + // A timestamp, in UTC, written out in an ISO 8601 format (compatible with + // the SQLite datetime function). + static const char FORMAT_ISO8601[]; + // Similar to the above, but including a timezone offset. + static const char FORMAT_LOCALTIME[]; + + static std::string format(time_t timestamp, const char *format, bool utc); + + static std::string isoformat(time_t timestamp) + { return format(timestamp, FORMAT_ISO8601, true); } + +private: + TimeFormat() { } +}; + #endif // _LBS_TARSTORE_H