GodMode9i/arm9/source/date.cpp
Pk11 90c413f8fb
Fix clock using 12-hour and covering last character of the path (#189)
* Fix clock using 12-hour and covering last of path

* Simplify RetTime()
2022-08-09 18:53:50 -06:00

33 lines
555 B
C++

#include "date.h"
#include "language.h"
#include <stdio.h>
#include <string>
#include <time.h>
/**
* Get the current time formatted for the top bar.
* @return std::string containing the time.
*/
std::string RetTime()
{
return RetTime(STR_TIME_FORMAT.c_str());
}
/**
* Get the current time formatted as specified.
* @return std::string containing the time.
*/
std::string RetTime(const char *format)
{
time_t raw;
time(&raw);
const struct tm *Time = localtime(&raw);
char tmp[64];
strftime(tmp, sizeof(tmp), format, Time);
return tmp;
}