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