Skip to content

Commit

Permalink
src: change getCurrentTimestamp() to use only c++ functions
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurmco committed Jul 19, 2024
1 parent 93a21a4 commit 2cce8d4
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

#include <cstdlib> /* getenv() */
#include <iostream>
#include <chrono>

#include <boost/process.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include <fmt/format.h>

#include <cloysterhpc/services/log.h>

#include <fmt/format.h>
#include <fmt/chrono.h>
#include <fstream>

namespace cloyster {
Expand Down Expand Up @@ -151,11 +153,13 @@ void removeFile(std::string_view filename)
*/
std::string getCurrentTimestamp()
{
time_t now;
time(&now);
char buf[sizeof "2011-10-08T07:07:09Z"];
strftime(buf, sizeof buf, "%FT%TZ", gmtime(&now));
return buf;
using clock = std::chrono::system_clock;
using sec = std::chrono::seconds;

std::chrono::time_point<clock> current_time = clock::now();
auto result = fmt::format("{:%FT%TZ}", std::chrono::time_point_cast<sec>(current_time));

return result;
}

/* Backup file */
Expand Down

0 comments on commit 2cce8d4

Please sign in to comment.