Skip to content
Snippets Groups Projects
Commit eed3d9b6 authored by deuce's avatar deuce
Browse files

Fix @UPTIME@ to return 0 if the uptime global isn't initialized yet, or

if time_t is unsigned and the current time is less than uptime.

There's comments that suggest the time(NULL) value is influenced by the
timezone, so possibly therre's a usage of it somewhere with the timezone
not being set comparing to an uptime that was set when timezone *was* set.
In this case, @UPTIME@ will say it's been up for zero days until the timezone
is set in that thread/process, or time(NULL) passes uptime.
parent da541a86
Branches
Tags
No related merge requests found
...@@ -147,9 +147,10 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen) ...@@ -147,9 +147,10 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
if(!strcmp(sp,"UPTIME")) { if(!strcmp(sp,"UPTIME")) {
extern volatile time_t uptime; extern volatile time_t uptime;
time_t up=time(NULL)-uptime; time_t up=0;
if(up<0) now = time(NULL);
up=0; if (uptime != 0 && now >= uptime)
up = now-uptime;
char days[64]=""; char days[64]="";
if((up/(24*60*60))>=2) { if((up/(24*60*60))>=2) {
sprintf(days,"%lu days ",(ulong)(up/(24L*60L*60L))); sprintf(days,"%lu days ",(ulong)(up/(24L*60L*60L)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment