CernVM-FS  2.12.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),
13  description_(description) {
14 }
15 
20  return HasPrefix(name_, "generic-", false);
21 }
22 
27  uint64_t nanoseconds = platform_realtime_ns();
28 
29  // Use strftime() to format timestamp to one-second resolution
30  time_t seconds = static_cast<time_t>(nanoseconds / 1000000000);
31  struct tm timestamp;
32  gmtime_r(&seconds, &timestamp);
33  char seconds_buffer[32];
34  strftime(seconds_buffer, sizeof(seconds_buffer),
35  "generic-%Y-%m-%dT%H:%M:%S", &timestamp);
36 
37  // Append milliseconds
38  unsigned offset_milliseconds = ((nanoseconds / 1000000) % 1000);
39  char name_buffer[48];
40  snprintf(name_buffer, sizeof(name_buffer), "%s.%03dZ", seconds_buffer,
41  offset_milliseconds);
42 
43  name_ = std::string(name_buffer);
44 }
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:267
bool HasGenericName()