summaryrefslogtreecommitdiff
path: root/src/KM_util.cpp
diff options
context:
space:
mode:
authormsheby <msheby@cinecert.com>2009-03-28 05:52:13 +0000
committermsheby <>2009-03-28 05:52:13 +0000
commit320ea14e5cc40fe38934209afeb71abf46bf03cb (patch)
treed650462e978a28a5939bbb0f0fcc46983eb9150a /src/KM_util.cpp
parent60480513f2dbf60bd659d86ac8b61c49b24322a7 (diff)
Strictly parse the minutes section of the time offset.
Add comments explaining the offset negation.
Diffstat (limited to 'src/KM_util.cpp')
-rwxr-xr-xsrc/KM_util.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/KM_util.cpp b/src/KM_util.cpp
index f0a779a..953159c 100755
--- a/src/KM_util.cpp
+++ b/src/KM_util.cpp
@@ -1021,16 +1021,19 @@ Kumu::Timestamp::DecodeString(const char* datestr)
char_count += 6;
- i32_t TZ_mm = 60 * atoi(datestr + 20);
- TZ_mm += atoi(datestr + 23);
- if (datestr[19] == '-')
- TZ_mm = -TZ_mm;
-
- if ((TZ_mm > 14 * 60) || (TZ_mm < -14 * 60))
+ ui32_t TZ_hh = atoi(datestr + 20);
+ ui32_t TZ_mm = atoi(datestr + 23);
+ if ((TZ_hh > 14) || (TZ_mm > 59) || ((TZ_hh == 14) && (TZ_mm > 0)))
return false;
- else
- TmpStamp.AddMinutes(-TZ_mm);
+ i32_t TZ_offset = 60 * TZ_hh + TZ_mm;
+ if (datestr[19] == '-')
+ TZ_offset = -TZ_offset;
+ /* at this point, TZ_offset reflects the contents of the string */
+
+ /* a negative offset is behind UTC and so needs to increment to
+ * convert, while a positive offset must do the reverse */
+ TmpStamp.AddMinutes(-TZ_offset);
}
else if (datestr[19] == 'Z')
{