getUtcOffset method
UTC offset for this DateTime as UTC+H:MM / UTC-H / UTC±0.
Reads the host timeZoneOffset, so the result depends on the running
environment's timezone — for deterministic formatting in tests, call the
top-level formatUtcOffset with a fixed Duration instead. Returns
null on any failure so a display string never throws. See
formatUtcOffset for the verbose/minute-eliding rules and examples.
Audited: 2026-06-12 11:26 EDT
Implementation
String? getUtcOffset({bool verbose = false}) {
try {
return formatUtcOffset(timeZoneOffset, verbose: verbose);
// Defensive: timeZoneOffset is host-provided; null on any failure.
// ignore: require_catch_logging -- display contract: never throw, callers fall back on null
} on Object {
return null;
}
}