Skip to content

Commit

Permalink
Add a comment about the time weirdness
Browse files Browse the repository at this point in the history
  • Loading branch information
drewroengoogle committed Sep 7, 2023
1 parent 3b64002 commit e5c230c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/src/common/model/repos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -462,14 +462,16 @@ class Repository {
@override
String toString() => 'Repository: $owner/$name';

/// In some cases, github webhooks send time values as an integer. This method
/// is added to handle those cases, but otherwise parse like normal.
static DateTime? dynamicToDateTime(dynamic time) {
if (time == null) {
return null;
}
if (time.runtimeType == int) {
return DateTime.fromMillisecondsSinceEpoch(time * 1000).toUtc();
return DateTime.fromMillisecondsSinceEpoch(time * 1000);
}
return DateTime.parse(time as String).toUtc();
return DateTime.parse(time as String);
}
}

Expand Down

0 comments on commit e5c230c

Please sign in to comment.