time_parser 1.2.1 time_parser: ^1.2.1 copied to clipboard
parses a time string and returns a time object in order to easily access hours and minutes.
example/time_parser_example.dart
import 'package:time_parser/time_parser.dart';
void main() {
var time = TimeParser.parse('15:30');
print('hours: ${time.hours}, minutes: ${time.minutes}');
// invalid time strings cause an TimeParseException
try {
TimeParser.parse('xx:xx');
} catch (e) {
print(e); // TimeParseException: invalid timeString: xx:xx
}
}