mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
bbbd4c8818
commit
4c85357dcc
4 changed files with 13 additions and 12 deletions
|
@ -204,8 +204,6 @@ extern void invalidate_dive_cache(struct dive *dc);
|
||||||
extern void set_autogroup(bool value);
|
extern void set_autogroup(bool value);
|
||||||
extern int total_weight(const struct dive *);
|
extern int total_weight(const struct dive *);
|
||||||
|
|
||||||
const char *monthname(int mon);
|
|
||||||
|
|
||||||
extern const char *existing_filename;
|
extern const char *existing_filename;
|
||||||
|
|
||||||
extern bool has_planned(const struct dive *dive, bool planned);
|
extern bool has_planned(const struct dive *dive, bool planned);
|
||||||
|
|
|
@ -18,6 +18,8 @@ extern int utc_weekday(timestamp_t timestamp);
|
||||||
extern timestamp_t parse_datetime(const char *s); /* returns 0 on error */
|
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 char *format_datetime(timestamp_t timestamp); /* ownership of string passed to caller */
|
||||||
|
|
||||||
|
extern const char *monthname(int mon);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -115,16 +115,6 @@ const struct units *get_units()
|
||||||
return &prefs.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
|
* track whether we switched to importing dives
|
||||||
*/
|
*/
|
||||||
|
|
11
core/time.c
11
core/time.c
|
@ -1,6 +1,7 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "subsurface-time.h"
|
#include "subsurface-time.h"
|
||||||
#include "subsurface-string.h"
|
#include "subsurface-string.h"
|
||||||
|
#include "gettext.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -213,3 +214,13 @@ extern char *format_datetime(timestamp_t timestamp)
|
||||||
|
|
||||||
return strdup(buf);
|
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]);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue