Skip to content

Commit 5ba214f

Browse files
committed
test [nfc]: Add utcTimestamp
1 parent e4a48de commit 5ba214f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/example_data.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@ ZulipApiException apiExceptionUnauthorized({String routeName = 'someRoute'}) {
6969
data: {}, message: 'Invalid API key');
7070
}
7171

72+
////////////////////////////////////////////////////////////////
73+
// Time values.
74+
//
75+
76+
final timeInPast = DateTime.utc(2025, 4, 1, 8, 30, 0);
77+
78+
/// The UNIX timestamp, in UTC seconds.
79+
///
80+
/// This is the commonly used format in the Zulip API for timestamps.
81+
int utcTimestamp([DateTime? dateTime]) {
82+
dateTime ??= timeInPast;
83+
return dateTime.toUtc().millisecondsSinceEpoch ~/ 1000;
84+
}
85+
7286
////////////////////////////////////////////////////////////////
7387
// Realm-wide (or server-wide) metadata.
7488
//

0 commit comments

Comments
 (0)