Fix isToday/isTomorrow day diff for UTC dates across timezone and DST boundaries - #80
Fix isToday/isTomorrow day diff for UTC dates across timezone and DST boundaries#80paul678 wants to merge 4 commits into
Conversation
Thus avoids daylight saving issues on isToday isTomorrow and wasYesterday
|
Could you please come up with a test case that would fail with the previous implementation and passes now? Thanks for noticing this! |
Added a very simple test. It is using the older I keep UTC dates throughout my app <-> backend communication and was doing a simple |
|
CC @jogboms For me, the old calculation on the test file is not needed, but since this is a test, I'm not that worried. Since I can't push new versions, anyway, I'll defer to the package owner. Again, thanks for the PR! |
|
Could you investigate the failing test? @paul678 |
|
@jogboms Sorry for the delay, got caught in some other stuff... |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #80 +/- ##
==========================================
- Coverage 99.85% 97.36% -2.50%
==========================================
Files 2 2
Lines 700 721 +21
==========================================
+ Hits 699 702 +3
- Misses 1 19 +18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| import 'package:timezone/timezone.dart' as tz; | ||
| import 'package:timezone/data/latest.dart' as tz; |
Summary
This changes
_calculateDifference(DateTime date)to preserve the timezone basis of the input date before comparing calendar days.Previously, the implementation rebuilt both values as local midnights:
That was incorrect when date was UTC, because the UTC date was implicitly converted into a local calendar day before the comparison.