diff --git a/core/dive.h b/core/dive.h index 09ef61b42..a38236fc5 100644 --- a/core/dive.h +++ b/core/dive.h @@ -204,8 +204,6 @@ extern void invalidate_dive_cache(struct dive *dc); extern void set_autogroup(bool value); extern int total_weight(const struct dive *); -const char *monthname(int mon); - extern const char *existing_filename; extern bool has_planned(const struct dive *dive, bool planned); diff --git a/core/subsurface-time.h b/core/subsurface-time.h index 8d564753f..828a8ef02 100644 --- a/core/subsurface-time.h +++ b/core/subsurface-time.h @@ -18,6 +18,8 @@ extern int utc_weekday(timestamp_t timestamp); extern timestamp_t parse_datetime(const char *s); /* returns 0 on error */ extern char *format_datetime(timestamp_t timestamp); /* ownership of string passed to caller */ +extern const char *monthname(int mon); + #ifdef __cplusplus } #endif diff --git a/core/subsurfacestartup.c b/core/subsurfacestartup.c index c2e4dda04..23e17c7a7 100644 --- a/core/subsurfacestartup.c +++ b/core/subsurfacestartup.c @@ -115,16 +115,6 @@ const struct units *get_units() return &prefs.units; } -/* random helper functions, used here or elsewhere */ -const char *monthname(int mon) -{ - static const char month_array[12][4] = { - QT_TRANSLATE_NOOP("gettextFromC", "Jan"), QT_TRANSLATE_NOOP("gettextFromC", "Feb"), QT_TRANSLATE_NOOP("gettextFromC", "Mar"), QT_TRANSLATE_NOOP("gettextFromC", "Apr"), QT_TRANSLATE_NOOP("gettextFromC", "May"), QT_TRANSLATE_NOOP("gettextFromC", "Jun"), - QT_TRANSLATE_NOOP("gettextFromC", "Jul"), QT_TRANSLATE_NOOP("gettextFromC", "Aug"), QT_TRANSLATE_NOOP("gettextFromC", "Sep"), QT_TRANSLATE_NOOP("gettextFromC", "Oct"), QT_TRANSLATE_NOOP("gettextFromC", "Nov"), QT_TRANSLATE_NOOP("gettextFromC", "Dec"), - }; - return translate("gettextFromC", month_array[mon]); -} - /* * track whether we switched to importing dives */ diff --git a/core/time.c b/core/time.c index d5196e868..861d7b1d5 100644 --- a/core/time.c +++ b/core/time.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include "subsurface-time.h" #include "subsurface-string.h" +#include "gettext.h" #include #include #include @@ -213,3 +214,13 @@ extern char *format_datetime(timestamp_t timestamp) return strdup(buf); } + +/* Turn month (0-12) into three-character short name */ +const char *monthname(int mon) +{ + static const char month_array[12][4] = { + QT_TRANSLATE_NOOP("gettextFromC", "Jan"), QT_TRANSLATE_NOOP("gettextFromC", "Feb"), QT_TRANSLATE_NOOP("gettextFromC", "Mar"), QT_TRANSLATE_NOOP("gettextFromC", "Apr"), QT_TRANSLATE_NOOP("gettextFromC", "May"), QT_TRANSLATE_NOOP("gettextFromC", "Jun"), + QT_TRANSLATE_NOOP("gettextFromC", "Jul"), QT_TRANSLATE_NOOP("gettextFromC", "Aug"), QT_TRANSLATE_NOOP("gettextFromC", "Sep"), QT_TRANSLATE_NOOP("gettextFromC", "Oct"), QT_TRANSLATE_NOOP("gettextFromC", "Nov"), QT_TRANSLATE_NOOP("gettextFromC", "Dec"), + }; + return translate("gettextFromC", month_array[mon]); +}