Hlc.parse constructor

Hlc.parse(
  1. String timestamp
)

Parse an HLC string in the format ISO8601 date-counter-node id.

Implementation

factory Hlc.parse(String timestamp) {
  final counterDash = timestamp.indexOf('-', timestamp.lastIndexOf(':'));
  final nodeIdDash = timestamp.indexOf('-', counterDash + 1);
  final dateTime = DateTime.parse(timestamp.substring(0, counterDash));
  final counter =
      int.parse(timestamp.substring(counterDash + 1, nodeIdDash), radix: 16);
  final nodeId = timestamp.substring(nodeIdDash + 1);
  return Hlc(dateTime, counter, nodeId);
}