refactor: Rename date parsing helper functions for consistency
This commit is contained in:
@@ -243,7 +243,7 @@ class ContainerModel {
|
||||
/// Factory depuis Firestore
|
||||
factory ContainerModel.fromMap(Map<String, dynamic> map, String id) {
|
||||
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
||||
DateTime? _parseDate(dynamic value) {
|
||||
DateTime? parseDate(dynamic value) {
|
||||
if (value == null) return null;
|
||||
if (value is Timestamp) return value.toDate();
|
||||
if (value is String) return DateTime.tryParse(value);
|
||||
@@ -270,8 +270,8 @@ class ContainerModel {
|
||||
equipmentIds: equipmentIds,
|
||||
eventId: map['eventId'],
|
||||
notes: map['notes'],
|
||||
createdAt: _parseDate(map['createdAt']) ?? DateTime.now(),
|
||||
updatedAt: _parseDate(map['updatedAt']) ?? DateTime.now(),
|
||||
createdAt: parseDate(map['createdAt']) ?? DateTime.now(),
|
||||
updatedAt: parseDate(map['updatedAt']) ?? DateTime.now(),
|
||||
history: history,
|
||||
);
|
||||
}
|
||||
@@ -351,7 +351,7 @@ class ContainerHistoryEntry {
|
||||
|
||||
factory ContainerHistoryEntry.fromMap(Map<String, dynamic> map) {
|
||||
// Helper pour parser la date
|
||||
DateTime _parseDate(dynamic value) {
|
||||
DateTime parseDate(dynamic value) {
|
||||
if (value == null) return DateTime.now();
|
||||
if (value is Timestamp) return value.toDate();
|
||||
if (value is String) return DateTime.tryParse(value) ?? DateTime.now();
|
||||
@@ -359,7 +359,7 @@ class ContainerHistoryEntry {
|
||||
}
|
||||
|
||||
return ContainerHistoryEntry(
|
||||
timestamp: _parseDate(map['timestamp']),
|
||||
timestamp: parseDate(map['timestamp']),
|
||||
action: map['action'] ?? '',
|
||||
equipmentId: map['equipmentId'],
|
||||
previousValue: map['previousValue'],
|
||||
|
||||
Reference in New Issue
Block a user