MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / parse

Method parse

src/common/TimeZoneUtil.cpp:457–503  ·  view source on GitHub ↗

Parses a time zone, offset- or region-based.

Source from the content-addressed store, hash-verified

455
456// Parses a time zone, offset- or region-based.
457USHORT TimeZoneUtil::parse(const char* str, unsigned strLen, bool strict)
458{
459 // Non-strict parse is used to detect OS time zone.
460
461 const char* end = str + strLen;
462 const char* p = str;
463
464 skipSpaces(p, end);
465
466 const auto start = str;
467
468 if (p < end && (*p == '-' || *p == '+'))
469 {
470 int sign = *p++ == '-' ? -1 : 1;
471 skipSpaces(p, end);
472
473 int tzh = parseNumber(p, end);
474
475 if (tzh >= 0)
476 {
477 skipSpaces(p, end);
478
479 if (!strict && p == end)
480 return makeFromOffset(sign, tzh, 0);
481
482 if (p < end && *p == ':')
483 {
484 ++p;
485 skipSpaces(p, end);
486 int tzm = parseNumber(p, end);
487
488 if (tzm >= 0)
489 {
490 skipSpaces(p, end);
491
492 if (p == end)
493 return makeFromOffset(sign, tzh, tzm);
494 }
495 }
496 }
497
498 status_exception::raise(Arg::Gds(isc_invalid_timezone_offset) << string(start, end));
499 return 0; // avoid warning
500 }
501
502 return parseRegion(p, str + strLen - p);
503}
504
505// Parses a time zone id from a region string.
506USHORT TimeZoneUtil::parseRegion(const char* str, unsigned strLen)

Callers

nothing calls this directly

Calls 5

skipSpacesFunction · 0.85
parseNumberFunction · 0.85
makeFromOffsetFunction · 0.85
raiseFunction · 0.85
GdsClass · 0.85

Tested by

no test coverage detected