Skip to content

Commit

Permalink
fix: Handle integer expiry date #3038
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Oct 31, 2024
1 parent 154de98 commit 0ef7731
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lib/app/shared/date/date.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,15 @@ class UiDate {
return null;
}
}

static DateTime parseExpirationDate(String input) {
if (RegExp(r'^\d+$').hasMatch(input)) {
// numeric date string
final int timestamp = int.parse(input);
return DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
} else {
// ISO 8601 formatted date string
return DateTime.parse(input);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class CredentialDetailsCubit extends Cubit<CredentialDetailsState> {

if (item.expirationDate != null) {
final DateTime dateTimeExpirationDate =
DateTime.parse(item.expirationDate!);
UiDate.parseExpirationDate(item.expirationDate!);
if (!dateTimeExpirationDate.isAfter(DateTime.now())) {
emit(
state.copyWith(
Expand Down

0 comments on commit 0ef7731

Please sign in to comment.