normalizeWireTimestamp function

String normalizeWireTimestamp(
  1. String value
)

An RFC 3339 UTC Z timestamp in FFX's canonical form, exactly six fraction digits (schema normalizeTimestamp, 18 ยง10): the form every stored timestamp has, and every timestamp param once FFX binds it. value must already be such a string, with up to nine fraction digits.

Implementation

String normalizeWireTimestamp(String value) {
  final dot = value.indexOf('.');
  final head = value.substring(0, dot < 0 ? value.length - 1 : dot);
  final digits = dot < 0 ? '' : value.substring(dot + 1, value.length - 1);
  return '$head.${digits.padRight(6, '0').substring(0, 6)}Z';
}