// SPDX-FileCopyrightText: 2026 FocusFlow contributors
// SPDX-License-Identifier: AGPL-3.0-only

part of '../../persistence_contract.dart';

/// DateTime storage convention for future document persistence.
abstract final class PersistenceDateTimeConvention {
  /// Human-readable convention kept close to the helper for tests and docs.
  static const description =
      'Store DateTime values as UTC ISO-8601 strings and compare as UTC instants.';

  /// Convert a DateTime into the persisted string convention.
  static String toStoredString(DateTime value) {
    return value.toUtc().toIso8601String();
  }

  /// Parse a persisted DateTime string back into a UTC DateTime.
  static DateTime fromStoredString(String value) {
    return DateTime.parse(value).toUtc();
  }

  /// Compare two DateTime values by their UTC instant.
  static int compare(DateTime left, DateTime right) {
    return left.toUtc().compareTo(right.toUtc());
  }
}
