diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-12-08 13:32:46 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-12-29 08:34:09 -0800 |
commit | 4c85357dccf489110efe0439dde597843c7a8771 (patch) | |
tree | 8f7dd2387b54b6202f61606aa01fc8227bde381e /core/time.c | |
parent | bbbd4c88180d43604c5e6bbe093461e93859d706 (diff) | |
download | subsurface-4c85357dccf489110efe0439dde597843c7a8771.tar.gz |
cleanup: move monthname to time.c
Weirdly, this function was declared in dive.h and defined in
subsurface-startup.c. Let's move declaration and definition to
more appropriate places, viz. subsurface-time.h and time.c.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/time.c')
-rw-r--r-- | core/time.c | 11 |
1 files changed, 11 insertions, 0 deletions
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 <string.h> #include <stdio.h> #include <stdlib.h> @@ -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]); +} |