#include "time.hpp"
#include <stdio.h>
using namespace std;
time_t current_time;
string current_time_name;
string time_to_name(time_t *t)
{
struct tm *timeinfo;
char name[80];
timeinfo = localtime(t);
sprintf(name, "%04d-%02d-%02d_%02d.%02d.%02d",
timeinfo->tm_year + 1900,
timeinfo->tm_mon + 1,
timeinfo->tm_mday,
timeinfo->tm_hour,
timeinfo->tm_min,
timeinfo->tm_sec);
return string(name);
}
string time_to_touch(time_t *t)
{
struct tm *timeinfo;
char name[80];
timeinfo = localtime(t);
sprintf(name, "%04d%02d%02d%02d%02d.%02d",
timeinfo->tm_year + 1900,
timeinfo->tm_mon + 1,
timeinfo->tm_mday,
timeinfo->tm_hour,
timeinfo->tm_min,
timeinfo->tm_sec);
return string(name);
}
void compute_current_time()
{
time(¤t_time);
current_time_name = time_to_name(¤t_time);
}