You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
void main() {
final x = DateTime(2022, 12, 31);
final y = DateTime(2023, 3, 12);
final z = DateTime(2023, 3, 13);
final foo = y.difference(x).inDays;
final bar = z.difference(x).inDays;
print(foo);
print(bar);
}
Result:
71
71
There are 71 days between Dec. 31st and March 12, but not March 13.
The text was updated successfully, but these errors were encountered:
Correct. Daylight saving starts at 2 AM, at which point the time zone changes so that it's now 3 AM.
No time passed between the two, it's the same point in time.
Use UTC time if you want to work with dates only.
The inDays really means "in multiples of 24 hours", and some calendar days have 23 or 25 hours.
So, working as designed. You can't ignore daylight saving when using local-time DateTimes.
void main() {
final x = DateTime(2022, 12, 31);
final y = DateTime(2023, 3, 12);
final z = DateTime(2023, 3, 13);
final foo = y.difference(x).inDays;
final bar = z.difference(x).inDays;
print(foo);
print(bar);
}
Result:
71
71
There are 71 days between Dec. 31st and March 12, but not March 13.
The text was updated successfully, but these errors were encountered: