formatIndiTimestamp function Protocol

String formatIndiTimestamp(
  1. DateTime time
)

Formats time as an INDI timestamp (YYYY-MM-DDTHH:MM:SS, in UTC).

Implementation

String formatIndiTimestamp(DateTime time) {
  final utc = time.toUtc();
  String two(int n) => n.toString().padLeft(2, '0');
  return '${utc.year.toString().padLeft(4, '0')}-${two(utc.month)}-'
      '${two(utc.day)}T${two(utc.hour)}:${two(utc.minute)}:${two(utc.second)}';
}