aboutsummaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-08 12:29:06 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-08 12:29:06 -0700
commitf297d9f91e5919c180d15be9562b8e15e6dd368e (patch)
tree835c8cf943badd99daeca1ab53c10b3d59c0c3a8 /save-xml.c
parentc054b18b7055473279b7120d334c453d1c0427ec (diff)
downloadsubsurface-f297d9f91e5919c180d15be9562b8e15e6dd368e.tar.gz
Fix picture loading
Signed vs unsigned comparisons are such a pain. Since we want offsets to be +/- 30 minutes around the dive we need to allow negative offsets - but duration_t was defined as uint32_t. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-xml.c')
-rw-r--r--save-xml.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/save-xml.c b/save-xml.c
index 4cebc3d61..514600dd4 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -333,8 +333,15 @@ static void save_picture(struct membuffer *b, struct picture *pic)
put_string(b, " <picture filename='");
put_string(b, pic->filename);
put_string(b, "'");
- if (pic->offset.seconds)
- put_format(b, " offset='%u:%02u min'", FRACTION(pic->offset.seconds, 60));
+ if (pic->offset.seconds) {
+ int offset = pic->offset.seconds;
+ char sign = '+';
+ if (offset < 0) {
+ sign = '-';
+ offset = -offset;
+ }
+ put_format(b, " offset='%c%u:%02u min'", sign, FRACTION(offset, 60));
+ }
if (pic->latitude.udeg || pic->longitude.udeg) {
put_degrees(b, pic->latitude, " gps='", " ");
put_degrees(b, pic->longitude, "", "'");