Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/tdpak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,24 +424,22 @@ const char* tdtis( // Convert integer format time to string

// Returns s
{
char* sbeg;
const char* apchar;
int hour;

if (!s)
s = strtemp( TDTIMELENMAX);
sbeg = s; // save beginning to return
hour = itm->hour; // fetch hour for possible adjustment
char* sbeg = s; // save beginning to return
int hour = itm->hour; // fetch hour for possible adjustment
if (Td24hrtime) // global 24-hour time format flag
apchar = ""; // no am/pm
else // not 24 hour time
{
apchar = (hour < 12) ? " am" : " pm"; // get am or pm to append
hour = (hour+11)%12 + 1; // convert 0..23 to 1..12
}
s += snprintf( s, sizeof(s), "%d:%2.2d", hour, itm->min); // format hour:min, point to end
s += snprintf( s, TDTIMELENMAX, "%d:%2.2d", hour, itm->min); // format hour:min, point to end
if (itm->sec != -1) // seconds -1 --> no display
snprintf( s, sizeof(s), ":%2.2d", itm->sec); // format & append :seconds
snprintf( s, TDTIMELENMAX, ":%2.2d", itm->sec); // format & append :seconds
return strcat( sbeg, apchar); // append am/pm if any and return
} // tdtis

Expand Down
Loading