Translatable DateTime (see #2335)
This commit is contained in:
parent
6318e8c8f8
commit
ca107bf159
@ -19,6 +19,7 @@
|
||||
#include "utils/time.hpp"
|
||||
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
@ -38,6 +39,21 @@ void StkTime::init()
|
||||
m_timer->grab();
|
||||
} // init
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/** Converts the time in this object to a human readable string. */
|
||||
std::string StkTime::toString(const TimeType &tt)
|
||||
{
|
||||
const struct tm *t = gmtime(&tt);
|
||||
|
||||
core::stringw w_date_format = translations->w_gettext(N_("%d/%m/%Y"));
|
||||
core::stringc c_date_format(w_date_format.c_str());
|
||||
|
||||
char s[64];
|
||||
strftime(s, 64, c_date_format.c_str(), t);
|
||||
return s;
|
||||
} // toString
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Returns a time based on an arbitrary 'epoch' (e.g. could be start
|
||||
* time of the application, 1.1.1970, ...).
|
||||
|
@ -52,13 +52,7 @@ public:
|
||||
static void getDate(int *day=NULL, int *month=NULL, int *year=NULL);
|
||||
|
||||
/** Converts the time in this object to a human readable string. */
|
||||
static std::string toString(const TimeType &tt)
|
||||
{
|
||||
const struct tm *t = gmtime(&tt);
|
||||
char s[16];
|
||||
strftime(s, 16, "%x", t);
|
||||
return s;
|
||||
} // toString
|
||||
static std::string toString(const TimeType &tt);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the number of seconds since 1.1.1970. This function is used
|
||||
* to compare access times of files, e.g. news, addons data etc.
|
||||
|
Loading…
Reference in New Issue
Block a user