mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
1e0bc8a1ab
commit
4587f8a274
3 changed files with 21 additions and 17 deletions
|
@ -258,7 +258,6 @@ static void date_data_func(GtkTreeViewColumn *col,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
int idx, nr;
|
int idx, nr;
|
||||||
struct tm tm;
|
|
||||||
timestamp_t when;
|
timestamp_t when;
|
||||||
/* this should be enought for most languages. if not increase the value. */
|
/* this should be enought for most languages. if not increase the value. */
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
@ -266,11 +265,10 @@ static void date_data_func(GtkTreeViewColumn *col,
|
||||||
gtk_tree_model_get(model, iter, DIVE_INDEX, &idx, DIVE_DATE, &when, -1);
|
gtk_tree_model_get(model, iter, DIVE_INDEX, &idx, DIVE_DATE, &when, -1);
|
||||||
nr = gtk_tree_model_iter_n_children(model, iter);
|
nr = gtk_tree_model_iter_n_children(model, iter);
|
||||||
|
|
||||||
utc_mkdate(when, &tm);
|
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
buffer = get_trip_date_string(&tm, nr);
|
buffer = get_trip_date_string(when, nr);
|
||||||
} else {
|
} else {
|
||||||
buffer = get_dive_date_string(&tm);
|
buffer = get_dive_date_string(when);
|
||||||
}
|
}
|
||||||
g_object_set(renderer, "text", buffer, NULL);
|
g_object_set(renderer, "text", buffer, NULL);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
28
divelist.c
28
divelist.c
|
@ -561,31 +561,37 @@ void get_suit(struct dive *dive, char **str)
|
||||||
|
|
||||||
#define MAX_DATE_STRING 256
|
#define MAX_DATE_STRING 256
|
||||||
/* caller needs to free the string */
|
/* 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);
|
char *buffer = malloc(MAX_DATE_STRING);
|
||||||
if (buffer)
|
if (buffer) {
|
||||||
|
struct tm tm;
|
||||||
|
utc_mkdate(when, &tm);
|
||||||
snprintf(buffer, MAX_DATE_STRING,
|
snprintf(buffer, MAX_DATE_STRING,
|
||||||
/*++GETTEXT 60 char buffer weekday, monthname, day of month, year, hour:min */
|
/*++GETTEXT 60 char buffer weekday, monthname, day of month, year, hour:min */
|
||||||
_("%1$s, %2$s %3$d, %4$d %5$02d:%6$02d"),
|
_("%1$s, %2$s %3$d, %4$d %5$02d:%6$02d"),
|
||||||
weekday(tm->tm_wday),
|
weekday(tm.tm_wday),
|
||||||
monthname(tm->tm_mon),
|
monthname(tm.tm_mon),
|
||||||
tm->tm_mday, tm->tm_year + 1900,
|
tm.tm_mday, tm.tm_year + 1900,
|
||||||
tm->tm_hour, tm->tm_min);
|
tm.tm_hour, tm.tm_min);
|
||||||
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* caller needs to free the string */
|
/* 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);
|
char *buffer = malloc(MAX_DATE_STRING);
|
||||||
if (buffer)
|
if (buffer) {
|
||||||
|
struct tm tm;
|
||||||
|
utc_mkdate(when, &tm);
|
||||||
snprintf(buffer, MAX_DATE_STRING,
|
snprintf(buffer, MAX_DATE_STRING,
|
||||||
/*++GETTEXT 60 char buffer weekday, monthname, day of month, year, nr dives */
|
/*++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)",
|
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),
|
"Trip %1$s, %2$s %3$d, %4$d (%5$d dives)", nr),
|
||||||
weekday(tm->tm_wday),
|
weekday(tm.tm_wday),
|
||||||
monthname(tm->tm_mon),
|
monthname(tm.tm_mon),
|
||||||
tm->tm_mday, tm->tm_year + 1900,
|
tm.tm_mday, tm.tm_year + 1900,
|
||||||
nr);
|
nr);
|
||||||
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ extern void export_all_dives_uddf_cb();
|
||||||
|
|
||||||
/* divelist core logic functions */
|
/* divelist core logic functions */
|
||||||
extern void process_dives(bool imported, bool prefer_imported);
|
extern void process_dives(bool imported, bool prefer_imported);
|
||||||
extern char *get_dive_date_string(struct tm *tm);
|
extern char *get_dive_date_string(timestamp_t when);
|
||||||
extern char *get_trip_date_string(struct tm *tm, int nr);
|
extern char *get_trip_date_string(timestamp_t when, int nr);
|
||||||
extern void clear_trip_indexes(void);
|
extern void clear_trip_indexes(void);
|
||||||
extern dive_trip_t *find_trip_by_idx(int idx);
|
extern dive_trip_t *find_trip_by_idx(int idx);
|
||||||
extern int dive_nr_sort(int idx_a, int idx_b, timestamp_t when_a, timestamp_t when_b);
|
extern int dive_nr_sort(int idx_a, int idx_b, timestamp_t when_a, timestamp_t when_b);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue