Replace localtime with thread safe function

This commit is contained in:
Vivek Kumar Dutta 2026-01-13 12:05:47 +05:30
parent b956fff5dc
commit b86e64ae69
No known key found for this signature in database
GPG key ID: 4E09F5AD8265FD4C
2 changed files with 6 additions and 6 deletions

View file

@ -938,10 +938,10 @@ int get_shift_utc_time(int shift_time, char *utc_time, int size)
int get_shift_time_time(int shift_time, char *local_time, int size)
{
time_t t_time;
struct tm *t_tm;
struct tm *t_tm, tm_local;
t_time = time(NULL) + shift_time;
t_tm = localtime(&t_time);
t_tm = localtime_r(&t_time, &tm_local);
if (t_tm == NULL)
return -1;
@ -1067,11 +1067,11 @@ int dm_time_utc_format(time_t ts, char **dst)
int dm_time_format(time_t ts, char **dst)
{
char time_buf[32] = { 0, 0 };
struct tm *t_tm;
struct tm *t_tm, tm_local;
*dst = dmstrdup("0001-01-01T00:00:00+00:00");
t_tm = localtime(&ts);
t_tm = localtime_r(&ts, &tm_local);
if (t_tm == NULL)
return -1;

View file

@ -40,7 +40,7 @@ static int dayname_to_week_day(const char *day)
static char *get_status(char *start, char *period, char *day)
{
struct tm *info = NULL;
struct tm *info = NULL, tm_local;
unsigned int s_day, s_hr, s_min, s_sec, e_day, e_hr, e_min, e_sec;
time_t ctime;
size_t length, i;
@ -51,7 +51,7 @@ static char *get_status(char *start, char *period, char *day)
return "Error";
time(&ctime);
info = localtime(&ctime);
info = localtime_r(&ctime, &tm_local);
if (!info)
return "Error";