From b0f9af53d6cc88205479813e6f12b18e266152ea Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Sun, 13 Nov 2011 01:17:03 +0000
Subject: [PATCH] Always display HH:MM:SS format when 24-hour (Military) time
 format is enabled in SCFG->System->Toggle Options.

---
 src/sbbs3/atcodes.cpp | 16 ++++++++++------
 src/sbbs3/con_out.cpp | 12 ++++++++----
 src/sbbs3/js_global.c | 12 ++++++++----
 3 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/src/sbbs3/atcodes.cpp b/src/sbbs3/atcodes.cpp
index 738408863b..dc954760d5 100644
--- a/src/sbbs3/atcodes.cpp
+++ b/src/sbbs3/atcodes.cpp
@@ -228,8 +228,8 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
 		memset(&tm,0,sizeof(tm));
 		localtime_r(&now,&tm);
 		if(cfg.sys_misc&SM_MILITARY)
-			safe_snprintf(str,maxlen,"%02d:%02d"
-		        	,tm.tm_hour,tm.tm_min);
+			safe_snprintf(str,maxlen,"%02d:%02d:%02d"
+		        	,tm.tm_hour,tm.tm_min,tm.tm_sec);
 		else
 			safe_snprintf(str,maxlen,"%02d:%02d %s"
 				,tm.tm_hour==0 ? 12
@@ -453,10 +453,14 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
 	if(!strcmp(sp,"LASTTIMEON")) {
 		memset(&tm,0,sizeof(tm));
 		localtime32(&useron.laston,&tm);
-		safe_snprintf(str,maxlen,"%02d:%02d %s"
-			,tm.tm_hour==0 ? 12
-			: tm.tm_hour>12 ? tm.tm_hour-12
-			: tm.tm_hour, tm.tm_min, tm.tm_hour>11 ? "pm":"am");
+		if(cfg.sys_misc&SM_MILITARY)
+			safe_snprintf(str,maxlen,"%02d:%02d:%02d"
+				,tm.tm_hour, tm.tm_min, tm.tm_sec);
+		else
+			safe_snprintf(str,maxlen,"%02d:%02d %s"
+				,tm.tm_hour==0 ? 12
+				: tm.tm_hour>12 ? tm.tm_hour-12
+				: tm.tm_hour, tm.tm_min, tm.tm_hour>11 ? "pm":"am");
 		return(str);
 	}
 
diff --git a/src/sbbs3/con_out.cpp b/src/sbbs3/con_out.cpp
index d14859dabf..6ff77a8d70 100644
--- a/src/sbbs3/con_out.cpp
+++ b/src/sbbs3/con_out.cpp
@@ -458,10 +458,14 @@ void sbbs_t::ctrl_a(char x)
 		case 'T':   /* Time */
 			now=time(NULL);
 			localtime_r(&now,&tm);
-			bprintf("%02d:%02d %s"
-				,tm.tm_hour==0 ? 12
-				: tm.tm_hour>12 ? tm.tm_hour-12
-				: tm.tm_hour, tm.tm_min, tm.tm_hour>11 ? "pm":"am");
+			if(cfg.sys_misc&SM_MILITARY)
+				bprintf("%02u:%02u:%02u"
+					,tm.tm_hour, tm.tm_min, tm.tm_sec);
+			else
+				bprintf("%02d:%02d %s"
+					,tm.tm_hour==0 ? 12
+					: tm.tm_hour>12 ? tm.tm_hour-12
+					: tm.tm_hour, tm.tm_min, tm.tm_hour>11 ? "pm":"am");
 			break;
 		case 'D':   /* Date */
 			now=time(NULL);
diff --git a/src/sbbs3/js_global.c b/src/sbbs3/js_global.c
index 7c19f57041..d0fd4297f4 100644
--- a/src/sbbs3/js_global.c
+++ b/src/sbbs3/js_global.c
@@ -1934,10 +1934,14 @@ js_html_encode(JSContext *cx, uintN argc, jsval *arglist)
 					case 'T':
 						now=time(NULL);
 						localtime_r(&now,&tm);
-						j+=sprintf(outbuf+j,"%02d:%02d %s"
-							,tm.tm_hour==0 ? 12
-							: tm.tm_hour>12 ? tm.tm_hour-12
-							: tm.tm_hour, tm.tm_min, tm.tm_hour>11 ? "pm":"am");
+						if(p->cfg->sys_misc&SM_MILITARY)
+							j+=sprintf(outbuf+j,"%02d:%02d:%02d"
+								,tm.tm_hour, tm.tm_min, tm.tm_sec);
+						else
+							j+=sprintf(outbuf+j,"%02d:%02d %s"
+								,tm.tm_hour==0 ? 12
+								: tm.tm_hour>12 ? tm.tm_hour-12
+								: tm.tm_hour, tm.tm_min, tm.tm_hour>11 ? "pm":"am");
 						break;
 						
 					case 'L':
-- 
GitLab