- if ( TZ_mm != 0 )
- DefaultLogSink().Error("Ignoring sub-hours timezone offset: %lu\n", TZ_mm);
-
- if ( TZ_hh > 12 )
- DefaultLogSink().Error("Ignoring large timezone offset: %s\n", (datestr+19));
- else
- AddHours(TZ_hh);
+ char_count += 3;
+ TmpStamp.Second = atoi(datestr + 17);
+ }
+
+ if ( datestr[19] == '.' )
+ {
+ if ( ! ( isdigit(datestr[20]) && isdigit(datestr[21]) && isdigit(datestr[22]) ) )
+ return false;
+
+ // we don't carry the ms value
+ datestr += 4;
+ }
+
+ if ( datestr[19] == '-' || datestr[19] == '+' )
+ {
+ if ( ! ( isdigit(datestr[20]) && isdigit(datestr[21]) )
+ || datestr[22] != ':'
+ || ! ( isdigit(datestr[23]) && isdigit(datestr[24]) ) )
+ return false;
+
+ char_count += 6;
+ ui32_t TZ_hh = atoi(datestr + 20);
+ ui32_t TZ_mm = atoi(datestr + 23);
+
+ if ( TZ_mm != 0 )
+ Kumu::DefaultLogSink().Warn("Ignoring minutes in timezone offset: %u\n", TZ_mm);
+
+ if ( TZ_hh > 12 )
+ return false;
+
+ else
+ AddHours( (datestr[19] == '-' ? (0 - TZ_hh) : TZ_hh));
+ }
+ }
+
+ if ( datestr[char_count] != 0 )
+ {
+ Kumu::DefaultLogSink().Error("Unexpected extra characters in string: %s (%ld)\n",
+ datestr, char_count);
+ return false;
+ }
+
+#ifdef KM_WIN32
+ SYSTEMTIME st;
+ FILETIME ft;
+ TIMESTAMP_TO_SYSTIME(TmpStamp, &st);
+ if ( SystemTimeToFileTime(&st, &ft) == 0 )
+ return false;
+ SYSTIME_TO_TIMESTAMP(&st, *this);
+#else
+ Kumu::TAI::tai t;
+ Kumu::TAI::caltime ct;
+ TIMESTAMP_TO_CALTIME(TmpStamp, &ct);
+ t = ct; // back and forth to tai to normalize offset
+ ct = t;
+ CALTIME_TO_TIMESTAMP(&ct, *this)
+#endif