-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Use case
Unlike DateTime, TimeOfDay does not have compareTo() method.
In order to compare 2 TimeOfDay objects, you have to use this awkward way:
- Create a helper extension:
extension TimeOfDayExt on TimeOfDay {
/// note: 'hour' is in 24-hour format
double toDouble() => hour + minute/60.0;
}- Convert both TimeOfDay's to double:
final double nowTime = TimeOfDay.now().toDouble();
final double deadlineTime = TimeOfDay.fromDateTime(deadline).toDouble();- Compare these doubles:
if (nowTime >= deadlineTime) {
// you're fired
}Proposal
Add a compareTo() method for TimeOfDay, so we can compare them directly.
IsaiasCuvula, rsegecin and nate-thegrate
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team