File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import 'package:intl/intl.dart' hide TextDirection;
8
8
9
9
import '../api/model/model.dart' ;
10
10
import '../generated/l10n/zulip_localizations.dart' ;
11
+ import '../model/binding.dart' ;
11
12
import '../model/database.dart' ;
12
13
import '../model/message.dart' ;
13
14
import '../model/message_list.dart' ;
@@ -1854,7 +1855,7 @@ class DateText extends StatelessWidget {
1854
1855
formatHeaderDate (
1855
1856
zulipLocalizations,
1856
1857
DateTime .fromMillisecondsSinceEpoch (timestamp * 1000 ),
1857
- now: DateTime . now ()));
1858
+ now: ZulipBinding .instance. utcNow (). toLocal ()));
1858
1859
}
1859
1860
}
1860
1861
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import 'dart:convert';
2
2
import 'dart:io' ;
3
3
4
4
import 'package:checks/checks.dart' ;
5
+ import 'package:clock/clock.dart' ;
5
6
import 'package:collection/collection.dart' ;
6
7
import 'package:flutter/material.dart' ;
7
8
import 'package:flutter/rendering.dart' ;
@@ -1654,8 +1655,16 @@ void main() {
1654
1655
];
1655
1656
for (final (dateTime, expected) in testCases) {
1656
1657
test ('$dateTime returns $expected ' , () {
1657
- check (formatHeaderDate (zulipLocalizations, DateTime .parse (dateTime), now: now))
1658
- .equals (expected);
1658
+ addTearDown (testBinding.reset);
1659
+
1660
+ withClock (Clock .fixed (now), () {
1661
+ check (formatHeaderDate (
1662
+ zulipLocalizations,
1663
+ DateTime .parse (dateTime),
1664
+ now: testBinding.utcNow ().toLocal (),
1665
+ ))
1666
+ .equals (expected);
1667
+ });
1659
1668
});
1660
1669
}
1661
1670
});
You can’t perform that action at this time.
0 commit comments