ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
provenance_header.h
Go to the documentation of this file.
1#ifndef MODULEIO_PROVENANCE_HEADER_H
2#define MODULEIO_PROVENANCE_HEADER_H
3
6
7#include <ctime>
8#include <string>
9
10namespace ModuleIO
11{
12
16inline std::string local_timestamp()
17{
18 const std::time_t now = std::time(nullptr);
19 std::tm tm_local;
20 localtime_r(&now, &tm_local);
21 char time_buf[64];
22 std::strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S", &tm_local);
23 return std::string(time_buf);
24}
25
30inline std::string provenance_header(const std::string& time_stamp)
31{
32 return FmtCore::format("# ABACUS version: %s\n# Written at %s\n",
33 VERSION,
34 time_stamp.c_str());
35}
36
38inline std::string prov_step(const int istep_one_based, const std::string& time_stamp)
39{
40 return FmtCore::format("# ABACUS version: %s\n# Written at %s\n# Ionic_Step %d\n",
41 VERSION,
42 time_stamp.c_str(),
43 istep_one_based);
44}
45
48inline std::string prov_inline(const std::string& time_stamp)
49{
50 return FmtCore::format(" # ABACUS version: %s # Written at %s",
51 VERSION,
52 time_stamp.c_str());
53}
54
55} // namespace ModuleIO
56
57#endif // MODULEIO_PROVENANCE_HEADER_H
static std::string format(const char *fmt, const Ts &... args)
static function to format data
Definition formatter.h:41
a new formatter library for formatting data
Internal helpers shared by the R-space sparse text writers. Declared here (instead of duplicated in e...
Definition csr_reader.cpp:8
std::string local_timestamp()
Definition provenance_header.h:16
std::string prov_step(const int istep_one_based, const std::string &time_stamp)
Two provenance lines followed by the unified "# Ionic_Step N" marker.
Definition provenance_header.h:38
std::string provenance_header(const std::string &time_stamp)
Definition provenance_header.h:30
std::string prov_inline(const std::string &time_stamp)
Definition provenance_header.h:48
#define VERSION
Definition version.h:2