@@ -72,27 +72,39 @@ EveTime::get_local_time_string (void)
72
72
/* ---------------------------------------------------------------- */
73
73
74
74
std::string
75
- EveTime::get_local_time_string ( time_t time , bool slim)
75
+ EveTime::get_time_string ( struct tm * tm , bool slim)
76
76
{
77
+ // If we wind up with an invalid time, we don't want to crash,
78
+ // so we return a string indicating something has gone wrong.
79
+ if (!tm )
80
+ {
81
+ return " INVALID TIME" ;
82
+ }
83
+
77
84
static ConfValuePtr lf = Config::conf.get_value (" evetime.time_format" );
78
85
static ConfValuePtr sf = Config::conf.get_value (" evetime.time_short_format" );
79
86
80
87
char buffer[128 ];
81
- strftime (buffer, 128 , (slim ? **sf : **lf).c_str (), :: localtime (& time ) );
88
+ strftime (buffer, 128 , (slim ? **sf : **lf).c_str (), tm );
82
89
return std::string (buffer);
83
90
}
84
91
85
92
/* ---------------------------------------------------------------- */
86
93
87
94
std::string
88
- EveTime::get_gm_time_string (time_t time, bool slim)
95
+ EveTime::get_local_time_string (time_t time, bool slim)
89
96
{
90
- static ConfValuePtr lf = Config::conf.get_value (" evetime.time_format" );
91
- static ConfValuePtr sf = Config::conf.get_value (" evetime.time_short_format" );
97
+ struct tm tm ;
98
+ return EveTime::get_time_string (::localtime_r (&time , &tm ), slim);
99
+ }
92
100
93
- char buffer[128 ];
94
- strftime (buffer, 128 , (slim ? **sf : **lf).c_str (), ::gmtime (&time ));
95
- return std::string (buffer);
101
+ /* ---------------------------------------------------------------- */
102
+
103
+ std::string
104
+ EveTime::get_gm_time_string (time_t time, bool slim)
105
+ {
106
+ struct tm tm ;
107
+ return EveTime::get_time_string (::gmtime_r (&time , &tm ), slim);
96
108
}
97
109
98
110
/* ---------------------------------------------------------------- */
0 commit comments