@@ -70,6 +70,36 @@ std::string StkTime::toString(const TimeType &tt)
70
70
{
71
71
const struct tm *t = gmtime (&tt);
72
72
73
+ std::string date_format = getDateFormat ();
74
+
75
+ char s[64 ];
76
+ strftime (s, 64 , date_format.c_str (), t);
77
+ return s;
78
+ } // toString(1)
79
+
80
+ // ----------------------------------------------------------------------------
81
+
82
+ /* * Converts the date represented by year, month, day
83
+ * to a human readable string. */
84
+ std::string StkTime::toString (int year, int month, int day)
85
+ {
86
+ struct tm *t = new tm ();
87
+ t->tm_year = year - 1900 ;
88
+ t->tm_mon = month - 1 ;
89
+ t->tm_mday = day;
90
+
91
+ std::string date_format = getDateFormat ();
92
+
93
+ char s[64 ];
94
+ strftime (s, 64 , date_format.c_str (), t);
95
+ return s;
96
+ } // toString(3)
97
+
98
+ // ----------------------------------------------------------------------------
99
+
100
+ /* * Obtains the translated format of the time string. */
101
+ std::string StkTime::getDateFormat ()
102
+ {
73
103
// I18N: Format for dates (%d = day, %m = month, %Y = year). See http://www.cplusplus.com/reference/ctime/strftime/ for more info about date formats.
74
104
core::stringw w_date_format = translations->w_gettext (N_ (" %d/%m/%Y" ));
75
105
core::stringc c_date_format (w_date_format.c_str ());
@@ -82,9 +112,7 @@ std::string StkTime::toString(const TimeType &tt)
82
112
date_format = " %d/%m/%Y" ;
83
113
}
84
114
85
- char s[64 ];
86
- strftime (s, 64 , date_format.c_str (), t);
87
- return s;
115
+ return date_format;
88
116
} // toString
89
117
90
118
// ----------------------------------------------------------------------------
0 commit comments