mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-06-18 19:05:30 -04:00

* Add barebones RTC (actually GPIO) detect * RTC reading gotta clean up * Nicer printing * Add date sanity check (detect RTC presence) * Append RTC data to dumped saves mGBA-style if present * Actually allow restoring save with RTC included
31 lines
490 B
C++
31 lines
490 B
C++
#include "date.h"
|
|
|
|
#include "language.h"
|
|
|
|
#include <stdio.h>
|
|
#include <string>
|
|
#include <time.h>
|
|
|
|
/**
|
|
* Get the current time formatted as specified.
|
|
* @return std::string containing the time.
|
|
*/
|
|
std::string RetTime(const char *format, time_t *raw)
|
|
{
|
|
if (!format)
|
|
{
|
|
format = STR_TIME_FORMAT.c_str();
|
|
}
|
|
time_t systime;
|
|
if (!raw) {
|
|
raw = &systime;
|
|
time(raw);
|
|
}
|
|
const struct tm *Time = localtime(raw);
|
|
|
|
char tmp[64];
|
|
strftime(tmp, sizeof(tmp), format, Time);
|
|
|
|
return tmp;
|
|
}
|