formatDateAsIso8601WithMillisPrecision function

  1. @internal
String formatDateAsIso8601WithMillisPrecision(
  1. DateTime date
)

Formats a Date as ISO8601 and UTC with millis precision

Implementation

@internal
String formatDateAsIso8601WithMillisPrecision(DateTime date) {
  var iso = date.toIso8601String();
  final millisecondSeparatorIndex = iso.lastIndexOf('.');
  if (millisecondSeparatorIndex != -1) {
    // + 4 for millis precision
    iso = iso.substring(0, millisecondSeparatorIndex + 4);
  }
  // appends Z because the substring removed it
  return '${iso}Z';
}