mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Save and restore a "dive number"
Some people want to know how many dives they have under their belt, so let's save and restore the dive number if it exists. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
d1b30212ff
commit
6538e5bba0
3 changed files with 13 additions and 4 deletions
1
dive.h
1
dive.h
|
@ -128,6 +128,7 @@ struct sample {
|
||||||
#define MAX_CYLINDERS (8)
|
#define MAX_CYLINDERS (8)
|
||||||
|
|
||||||
struct dive {
|
struct dive {
|
||||||
|
int nr;
|
||||||
time_t when;
|
time_t when;
|
||||||
char *location;
|
char *location;
|
||||||
char *notes;
|
char *notes;
|
||||||
|
|
|
@ -609,7 +609,8 @@ static void divinglog_place(char *place, void *_location)
|
||||||
|
|
||||||
static int divinglog_dive_match(struct dive *dive, const char *name, int len, char *buf)
|
static int divinglog_dive_match(struct dive *dive, const char *name, int len, char *buf)
|
||||||
{
|
{
|
||||||
return MATCH(".divedate", divedate, &dive->when) ||
|
return MATCH(".id", get_index, &dive->nr) ||
|
||||||
|
MATCH(".divedate", divedate, &dive->when) ||
|
||||||
MATCH(".entrytime", divetime, &dive->when) ||
|
MATCH(".entrytime", divetime, &dive->when) ||
|
||||||
MATCH(".depth", depth, &dive->maxdepth) ||
|
MATCH(".depth", depth, &dive->maxdepth) ||
|
||||||
MATCH(".tanksize", cylindersize, &dive->cylinder[0].type.size) ||
|
MATCH(".tanksize", cylindersize, &dive->cylinder[0].type.size) ||
|
||||||
|
@ -876,6 +877,8 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (MATCH(".nr", get_index, &dive->nr))
|
||||||
|
return;
|
||||||
if (MATCH(".date", divedate, &dive->when))
|
if (MATCH(".date", divedate, &dive->when))
|
||||||
return;
|
return;
|
||||||
if (MATCH(".time", divetime, &dive->when))
|
if (MATCH(".time", divetime, &dive->when))
|
||||||
|
|
11
save-xml.c
11
save-xml.c
|
@ -205,9 +205,14 @@ static void save_dive(FILE *f, struct dive *dive)
|
||||||
int i;
|
int i;
|
||||||
struct tm *tm = gmtime(&dive->when);
|
struct tm *tm = gmtime(&dive->when);
|
||||||
|
|
||||||
fprintf(f, "<dive date='%04u-%02u-%02u' time='%02u:%02u:%02u' duration='%u:%02u min'>\n",
|
fputs("<dive", f);
|
||||||
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
|
if (dive->nr)
|
||||||
tm->tm_hour, tm->tm_min, tm->tm_sec,
|
fprintf(f, " nr='%d'", dive->nr);
|
||||||
|
fprintf(f, " date='%04u-%02u-%02u'",
|
||||||
|
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday);
|
||||||
|
fprintf(f, " time='%02u:%02u:%02u'",
|
||||||
|
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||||
|
fprintf(f, " duration='%u:%02u min'>\n",
|
||||||
FRACTION(dive->duration.seconds, 60));
|
FRACTION(dive->duration.seconds, 60));
|
||||||
save_overview(f, dive);
|
save_overview(f, dive);
|
||||||
save_cylinder_info(f, dive);
|
save_cylinder_info(f, dive);
|
||||||
|
|
Loading…
Add table
Reference in a new issue