[PATCH] don't use strftime() due to locale issues

Lubomir I. Ivanov neolit123 at gmail.com
Sun Nov 6 21:33:49 PST 2011


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

statistics.c
use snprintf() with weekday(), monthname() instead of strftime().

info.c
set value of hours in title bar to two diggits %02d

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 info.c       |    2 +-
 statistics.c |   10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/info.c b/info.c
index 75b34bb..dda6582 100644
--- a/info.c
+++ b/info.c
@@ -121,7 +121,7 @@ void show_dive_info(struct dive *dive)
 	if (*text) {
 		snprintf(buffer, sizeof(buffer), "Dive #%d - %s", dive->number, text);
 	} else {
-		snprintf(buffer, sizeof(buffer), "Dive #%d - %s %02d/%02d/%04d at %d:%02d",
+		snprintf(buffer, sizeof(buffer), "Dive #%d - %s %02d/%02d/%04d at %02d:%02d",
 			dive->number,
 			weekday(tm->tm_wday),
 			tm->tm_mon+1, tm->tm_mday,
diff --git a/statistics.c b/statistics.c
index d714220..5a74314 100644
--- a/statistics.c
+++ b/statistics.c
@@ -125,10 +125,18 @@ void show_dive_stats(struct dive *dive)
 	const char *unit;
 	int idx, offset, gas_used;
 	struct dive *prev_dive;
+	struct tm *tm;
 
 	process_all_dives(dive, &prev_dive);
+	
+	tm = gmtime(&dive->when);
+	snprintf(buf, sizeof(buf),
+		"%s, %s %d, %d %02d:%02d",
+		weekday(tm->tm_wday),
+		monthname(tm->tm_mon),
+		tm->tm_mday, tm->tm_year + 1900,
+		tm->tm_hour, tm->tm_min);
 
-	strftime(buf, 80, "%a, %b %d, %Y, %k:%M", gmtime(&dive->when));
 	set_label(info_stat_w.date, buf);
 	set_label(info_stat_w.dive_time, "%d min", (dive->duration.seconds + 30) / 60);
 	if (prev_dive)
-- 
1.7.6.msysgit.0



More information about the subsurface mailing list