fix(#112): dates et places AM en reprise (resetForReprise)
Corrige l’ombre des paramètres dateOfBirth, agreementDate et placesAvailable dans resetForReprise ; renforce le parsing reprise-dossier et ajoute un test. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -108,6 +108,15 @@ class RepriseMapper {
|
||||
static DateTime? parseIsoDate(String? raw) {
|
||||
if (raw == null || raw.trim().isEmpty) return null;
|
||||
final s = raw.trim();
|
||||
final iso = RegExp(r'^(\d{4})-(\d{2})-(\d{2})');
|
||||
final isoMatch = iso.firstMatch(s);
|
||||
if (isoMatch != null) {
|
||||
return DateTime(
|
||||
int.parse(isoMatch.group(1)!),
|
||||
int.parse(isoMatch.group(2)!),
|
||||
int.parse(isoMatch.group(3)!),
|
||||
);
|
||||
}
|
||||
try {
|
||||
return DateTime.parse(s);
|
||||
} catch (_) {
|
||||
@@ -128,10 +137,34 @@ class RepriseMapper {
|
||||
if (value == null) return null;
|
||||
if (value is String) {
|
||||
final s = value.trim();
|
||||
return s.isEmpty ? null : s;
|
||||
return s.isEmpty || s == 'null' ? null : s;
|
||||
}
|
||||
if (value is DateTime) return value.toIso8601String();
|
||||
return null;
|
||||
if (value is DateTime) {
|
||||
return '${value.year.toString().padLeft(4, '0')}-'
|
||||
'${value.month.toString().padLeft(2, '0')}-'
|
||||
'${value.day.toString().padLeft(2, '0')}';
|
||||
}
|
||||
if (value is num) {
|
||||
final ms = value.abs() > 9999999999
|
||||
? value.toInt()
|
||||
: value.toInt() * 1000;
|
||||
final dt = DateTime.fromMillisecondsSinceEpoch(ms, isUtc: true);
|
||||
return '${dt.year.toString().padLeft(4, '0')}-'
|
||||
'${dt.month.toString().padLeft(2, '0')}-'
|
||||
'${dt.day.toString().padLeft(2, '0')}';
|
||||
}
|
||||
if (value is Map) {
|
||||
final y = value['year'];
|
||||
final m = value['month'] ?? value['monthValue'];
|
||||
final d = value['day'] ?? value['dayOfMonth'];
|
||||
if (y is num && m is num && d is num) {
|
||||
return '${y.toInt().toString().padLeft(4, '0')}-'
|
||||
'${m.toInt().toString().padLeft(2, '0')}-'
|
||||
'${d.toInt().toString().padLeft(2, '0')}';
|
||||
}
|
||||
}
|
||||
final s = value.toString().trim();
|
||||
return s.isEmpty || s == 'null' ? null : s;
|
||||
}
|
||||
|
||||
static int? optionalInt(dynamic value) {
|
||||
|
||||
Reference in New Issue
Block a user