format method

String format()

Return ISO8601 String of format YYYY-MM-DD+hh:mm:ss

Implementation

String format() {
  final buffer = StringBuffer()
    // Extract date portion of DateTime.ISO8601String
    ..write(_dateTime.toIso8601String().substring(0, 10));

  // Duration.toString returns string of form -9:30:00.000000 / 9:30:00.000000
  // But we need -09:30 / +09:30
  if (_offset != null) {
    if (_offset.inSeconds == 0) {
      buffer.write('Z');
    } else {
      buffer.write(Temporal.durationToOffset(_offset));
    }
  }

  return buffer.toString();
}