+ if (end < 0) {
+ /* Assume an ascent/descent rate of 9 m/min */
+ int depth = dive->maxdepth.mm;
+ int asc_desc_time = depth*60/9000;
+ int duration = dive->duration.seconds;
+
+ /* Some sanity checks against insane dives */
+ if (duration < 2)
+ duration = 2;
+ if (asc_desc_time * 2 >= duration)
+ asc_desc_time = duration/2;
+
+ dive->meandepth.mm = depth*(duration-asc_desc_time)/duration;