std::string CrowService::ParseCreateTime()

in service/http_server/crow_service.cpp [515:547]


std::string CrowService::ParseCreateTime(uint64_t createtime) {
  std::string timestr = "";
  uint64_t sec = createtime / 1000000; // see resilientdb/common/utils/utils.cpp

  std::tm *tm_gmt = std::gmtime((time_t *)&sec);
  int year = tm_gmt->tm_year + 1900;
  int month = tm_gmt->tm_mon; // 0-indexed
  int day = tm_gmt->tm_mday;

  std::string months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
                            "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};

  // Using date time string format to support the Explorer transaction chart
  if (day < 10)
    timestr += "0";
  timestr += std::to_string(day) + " " + months[month] + " " +
             std::to_string(year) + " ";

  std::string hour_str = std::to_string(tm_gmt->tm_hour);
  std::string min_str = std::to_string(tm_gmt->tm_min);
  std::string sec_str = std::to_string(tm_gmt->tm_sec);

  if (tm_gmt->tm_hour < 10)
    hour_str = "0" + hour_str;
  if (tm_gmt->tm_min < 10)
    min_str = "0" + min_str;
  if (tm_gmt->tm_sec < 10)
    sec_str = "0" + sec_str;

  timestr += hour_str + ":" + min_str + ":" + sec_str + " GMT";

  return timestr;
}