CernVM-FS  2.13.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
repository_tag.cc
Go to the documentation of this file.
1 
5 #include "repository_tag.h"
6 
7 #include "util/platform.h"
8 #include "util/string.h"
9 
10 RepositoryTag::RepositoryTag(const std::string &name,
11  const std::string &description)
12  : name_(name), description_(description) { }
13 
18  return HasPrefix(name_, "generic-", false);
19 }
20 
25  const uint64_t nanoseconds = platform_realtime_ns();
26 
27  // Use strftime() to format timestamp to one-second resolution
28  const time_t seconds = static_cast<time_t>(nanoseconds / 1000000000);
29  struct tm timestamp;
30  gmtime_r(&seconds, &timestamp);
31  char seconds_buffer[32];
32  strftime(seconds_buffer, sizeof(seconds_buffer), "generic-%Y-%m-%dT%H:%M:%S",
33  &timestamp);
34 
35  // Append milliseconds
36  const unsigned offset_milliseconds = ((nanoseconds / 1000000) % 1000);
37  char name_buffer[48];
38  snprintf(name_buffer, sizeof(name_buffer), "%s.%03dZ", seconds_buffer,
39  offset_milliseconds);
40 
41  name_ = std::string(name_buffer);
42 }
void SetGenericName()
std::string name_
uint64_t platform_realtime_ns()
bool HasPrefix(const string &str, const string &prefix, const bool ignore_case)
Definition: string.cc:279
bool HasGenericName()