cyberhybridhub/lib/utils/guess_slot_format.dart

22 lines
810 B
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/// Labels for market-history session-half slot instants (UTC wire times).
String formatGuessSlotInstant(DateTime slotStart) {
final DateTime utc = slotStart.toUtc();
final String month = utc.month.toString().padLeft(2, '0');
final String day = utc.day.toString().padLeft(2, '0');
final String hour = utc.hour.toString().padLeft(2, '0');
final String minute = utc.minute.toString().padLeft(2, '0');
return '$month/$day $hour:$minute';
}
/// Active guess pair: older session half → next session half.
String formatGuessSlotRange({
required DateTime slotStart,
DateTime? newerSlotStart,
}) {
if (newerSlotStart == null) {
return '${formatGuessSlotInstant(slotStart)} UTC';
}
return '${formatGuessSlotInstant(slotStart)} '
'${formatGuessSlotInstant(newerSlotStart)} UTC';
}