toTzString method

String toTzString(
  1. bool inUtc, [
  2. int? numChars
])

Converts this date-time to a string in either local or UTC time zone. If numChars is provided, the string will be truncated to that length. Note that is inUtc is true, 'z' will be appended to the string regardless of numChars.

Implementation

String toTzString(
  final bool inUtc, [
  final int? numChars,
]) {
  final s = inUtc ? toUtc().toString() : toLocal().toString();
  final trunc = numChars == null ? s : s.substring(0, numChars);
  return inUtc && !trunc.endsWith('Z') ? '${trunc}z' : trunc;
}