summaryrefslogtreecommitdiffstats
path: root/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/parse.c b/parse.c
index 1a8e3ba61..f90c16ce1 100644
--- a/parse.c
+++ b/parse.c
@@ -391,10 +391,34 @@ static void dive_start(void)
memset(&tm, 0, sizeof(tm));
}
+static char *generate_name(struct dive *dive)
+{
+ int len;
+ struct tm *tm;
+ char buffer[256], *p;
+
+ tm = gmtime(&dive->when);
+
+ len = snprintf(buffer, sizeof(buffer),
+ "%04d-%02d-%02d "
+ "%02d:%02d:%02d "
+ "(%d ft, %d min)\n",
+ tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min, tm->tm_sec,
+ to_feet(dive->maxdepth), dive->duration.seconds / 60);
+ p = malloc(len+1);
+ if (!p)
+ exit(1);
+ memcpy(p, buffer, len+1);
+ return p;
+}
+
static void dive_end(void)
{
if (!dive)
return;
+ if (!dive->name)
+ dive->name = generate_name(dive);
record_dive(dive);
dive = NULL;
}