Skip to content

Commit d347a59

Browse files
committed
Merge remote-tracking branch 'origin/console-template-develop' into console-template-develop
2 parents 7bb166e + 0f488ea commit d347a59

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/digit_forms_engine/lib/utils/utils.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,15 @@ bool isHidden(PropertySchema property) {
152152

153153
/// Checks if the string can be parsed as a DateTime
154154
bool isDateTime(String input) {
155-
return DateTime.tryParse(input) != null;
155+
156+
if (RegExp(r'^\d{4}-\d{2}-\d{2}').hasMatch(input)) {
157+
return DateTime.tryParse(input) != null;// ISO 8601
158+
} else if (RegExp(r'^\d{2}/\d{2}/\d{4}$').hasMatch(input)) {
159+
return DateTime.tryParse(input) != null;
160+
}
161+
162+
return false;
163+
156164
}
157165

158166
bool isDateLike(String input) {
@@ -173,7 +181,7 @@ DateTime parseDate(String input) {
173181
final year = int.parse(parts[2]);
174182
return DateTime(year, month, day);
175183
}
176-
throw FormatException('Unsupported date format');
184+
throw const FormatException('Unsupported date format');
177185
}
178186

179187
bool isDotSeparatedKey(String input) {

0 commit comments

Comments
 (0)