aboutsummaryrefslogtreecommitdiffstats
path: root/divelist.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-04-24 21:05:57 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-04-24 21:05:57 -0700
commit4587f8a2744ed8286aa8912de75516deaf217f4e (patch)
tree4103e6c22a4b517ddc6824bca76f6b7fb1587632 /divelist.c
parent1e0bc8a1ab5d124445786266ad916744b1368986 (diff)
downloadsubsurface-4587f8a2744ed8286aa8912de75516deaf217f4e.tar.gz
Call the get_date functions with timestamp_t instead of struct tm
This is the much more natural way to use this function, now that I look at it... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r--divelist.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/divelist.c b/divelist.c
index bd1e90224..e34f7afeb 100644
--- a/divelist.c
+++ b/divelist.c
@@ -561,31 +561,37 @@ void get_suit(struct dive *dive, char **str)
#define MAX_DATE_STRING 256
/* caller needs to free the string */
-char *get_dive_date_string(struct tm *tm) {
+char *get_dive_date_string(timestamp_t when) {
char *buffer = malloc(MAX_DATE_STRING);
- if (buffer)
+ if (buffer) {
+ struct tm tm;
+ utc_mkdate(when, &tm);
snprintf(buffer, MAX_DATE_STRING,
/*++GETTEXT 60 char buffer weekday, monthname, day of month, year, hour:min */
_("%1$s, %2$s %3$d, %4$d %5$02d:%6$02d"),
- weekday(tm->tm_wday),
- monthname(tm->tm_mon),
- tm->tm_mday, tm->tm_year + 1900,
- tm->tm_hour, tm->tm_min);
+ weekday(tm.tm_wday),
+ monthname(tm.tm_mon),
+ tm.tm_mday, tm.tm_year + 1900,
+ tm.tm_hour, tm.tm_min);
+ }
return buffer;
}
/* caller needs to free the string */
-char *get_trip_date_string(struct tm *tm, int nr) {
+char *get_trip_date_string(timestamp_t when, int nr) {
char *buffer = malloc(MAX_DATE_STRING);
- if (buffer)
+ if (buffer) {
+ struct tm tm;
+ utc_mkdate(when, &tm);
snprintf(buffer, MAX_DATE_STRING,
/*++GETTEXT 60 char buffer weekday, monthname, day of month, year, nr dives */
ngettext("Trip %1$s, %2$s %3$d, %4$d (%5$d dive)",
"Trip %1$s, %2$s %3$d, %4$d (%5$d dives)", nr),
- weekday(tm->tm_wday),
- monthname(tm->tm_mon),
- tm->tm_mday, tm->tm_year + 1900,
+ weekday(tm.tm_wday),
+ monthname(tm.tm_mon),
+ tm.tm_mday, tm.tm_year + 1900,
nr);
+ }
return buffer;
}