-
Notifications
You must be signed in to change notification settings - Fork 134
Open
Description
Describe the bug
The method endOf is decribed as giving the last microsecond that belong to the unit given. In Chrome somehow this doesn't work. And therefore the function isSame doesnt work as expected either.
How to reproduce the bug
Her an Example to show the Bug:
Unit unit = Unit.month;
Jiffy first = Jiffy.parseFromDateTime(DateTime(2023,1,25));
Jiffy second = Jiffy.parseFromDateTime(DateTime(2023,2,1));
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: ListView(
children: <Widget>[
ListTile(
title: Text("Comparing following two dates"),
subtitle: Text(first.dateTime.toIso8601String() + " and " + second.dateTime.toIso8601String()),
),
Row(
children: [
Padding(
padding: EdgeInsets.only(left:16),
child: SizedBox(
width: 200,
child: DropdownButton<Unit>(
value: unit,
icon: const Icon(Icons.monetization_on),
onChanged: (Unit? value) {
setState(() {
unit = value!;
});
},
items: Unit.values.map<DropdownMenuItem<Unit>>((Unit value) {
return DropdownMenuItem<Unit>(
value: value,
child: Text(value.toString()),
);
}).toList(),
),
),
),
Expanded(child: SizedBox.shrink()),
],
),
ListTile(
title: Text("startOf works as intendent"),
subtitle: Text(first.startOf(unit).dateTime.toIso8601String() + " and " + second.startOf(unit).dateTime.toIso8601String()),
),
ListTile(
title: Text("but endOf doesnt work as intended in chrome"),
subtitle: Text(first.endOf(unit).dateTime.toIso8601String() + " and " + second.endOf(unit).dateTime.toIso8601String()),
),
ListTile(
title: Text("And Therefore isSame doesnt work as intended, here an Example for Unit Month"),
subtitle: Text("First and Second are the same in month unit: ${first.isSame(second,unit: Unit.month)}"),
)
],
),
);
}
What is the expected behavior
For the date 2023-01-25, endOf for the unit Unit.month should return 2023-01-25T23:59.59.999999. Also if comparing the Jiffy Dates 2023-01-25 and 2023-02-01 isSame should return false.
Screenshots
Additional information
Tested on :
Chrome 117.0.5938.92
Flutter 3.13.4
On Linux
In Debug Mode and as Release Version deployed on a server
raquelhortab and jigneshpandav
Metadata
Metadata
Assignees
Labels
No labels