@@ -96,21 +96,17 @@ static int print_status_info(const StatusInfo *i) {
9696 } else
9797 log_warning ("Could not get time from timedated and not operating locally, ignoring." );
9898
99- if (have_time )
100- n = strftime (a , sizeof a , "%a %Y-%m-%d %H:%M:%S %Z" , localtime_r (& sec , & tm ));
101-
99+ n = have_time ? strftime (a , sizeof a , "%a %Y-%m-%d %H:%M:%S %Z" , localtime_r (& sec , & tm )) : 0 ;
102100 r = table_add_many (table ,
103101 TABLE_STRING , "Local time:" ,
104- TABLE_STRING , have_time && n > 0 ? a : "n/a" );
102+ TABLE_STRING , n > 0 ? a : "n/a" );
105103 if (r < 0 )
106104 return table_log_add_error (r );
107105
108- if (have_time )
109- n = strftime (a , sizeof a , "%a %Y-%m-%d %H:%M:%S UTC" , gmtime_r (& sec , & tm ));
110-
106+ n = have_time ? strftime (a , sizeof a , "%a %Y-%m-%d %H:%M:%S UTC" , gmtime_r (& sec , & tm )) : 0 ;
111107 r = table_add_many (table ,
112108 TABLE_STRING , "Universal time:" ,
113- TABLE_STRING , have_time && n > 0 ? a : "n/a" );
109+ TABLE_STRING , n > 0 ? a : "n/a" );
114110 if (r < 0 )
115111 return table_log_add_error (r );
116112
@@ -119,26 +115,23 @@ static int print_status_info(const StatusInfo *i) {
119115
120116 rtc_sec = (time_t ) (i -> rtc_time / USEC_PER_SEC );
121117 n = strftime (a , sizeof a , "%a %Y-%m-%d %H:%M:%S" , gmtime_r (& rtc_sec , & tm ));
122- }
123-
118+ } else
119+ n = 0 ;
124120 r = table_add_many (table ,
125121 TABLE_STRING , "RTC time:" ,
126- TABLE_STRING , i -> rtc_time > 0 && n > 0 ? a : "n/a" );
122+ TABLE_STRING , n > 0 ? a : "n/a" );
127123 if (r < 0 )
128124 return table_log_add_error (r );
129125
130- if (have_time )
131- n = strftime (a , sizeof a , "%Z, %z" , localtime_r (& sec , & tm ));
132-
133126 r = table_add_cell (table , NULL , TABLE_STRING , "Time zone:" );
134127 if (r < 0 )
135128 return table_log_add_error (r );
136129
137- r = table_add_cell_stringf (table , NULL , "%s (%s)" , strna (i -> timezone ), have_time && n > 0 ? a : "n/a" );
130+ n = have_time ? strftime (a , sizeof a , "%Z, %z" , localtime_r (& sec , & tm )) : 0 ;
131+ r = table_add_cell_stringf (table , NULL , "%s (%s)" , strna (i -> timezone ), n > 0 ? a : "n/a" );
138132 if (r < 0 )
139133 return table_log_add_error (r );
140134
141-
142135 /* Restore the $TZ */
143136 r = set_unset_env ("TZ" , old_tz , true);
144137 if (r < 0 )
0 commit comments