-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Description
I tried to use this Cron: 0 19 7 8 *. This next event should be 2021-08-07 19:00:00. But this package returns 2021-08-01 19:00:00.
Test cases
import 'package:cronparse/cronparse.dart';
import 'package:test/test.dart';
void main() {
group("Cron", () {
final current = DateTime.parse('2021-07-11 13:00:01');
group('.next()', () {
test('"0 19 7 8 *" should return 7. August 2021', () {
final cron = Cron('0 19 7 8 *');
final next = cron.nextRelativeTo(current);
print("next: $next");
expect(cron.nextRelativeTo(current), DateTime.parse('2021-08-07 19:00:00'));
// Fails ❌
});
test('"0 19 7 * *" should return 7. August 2021', () {
final cron = Cron('0 19 7 * *');
final next = cron.nextRelativeTo(current);
print("next: $next");
expect(cron.nextRelativeTo(current), DateTime.parse('2021-08-07 19:00:00'));
// Fails ❌
});
test('"0 19 * 8 *" should return 1. August 2021', () {
final cron = Cron('0 19 * 8 *');
final next = cron.nextRelativeTo(current);
print("next: $next");
expect(cron.nextRelativeTo(current), DateTime.parse('2021-08-01 19:00:00'));
// Pass ✅
});
});
group('.previous()', () {
test('"0 19 7 8 *" should return 7. August 2020', () {
final cron = Cron('0 19 7 8 *');
final previous = cron.previousRelativeTo(current);
print("previous: $previous");
expect(cron.previousRelativeTo(current), DateTime.parse('2020-08-07 19:00:00'));
// Fails ❌
});
test('"0 19 7 * *" should return 7. July 2021', () {
final cron = Cron('0 19 7 * *');
final previous = cron.previousRelativeTo(current);
print("previous: $previous");
expect(cron.previousRelativeTo(current), DateTime.parse('2021-07-07 19:00:00'));
// Fails ❌
});
test('"0 19 * 8 *" should return 31. August 2020', () {
final cron = Cron('0 19 * 8 *');
final previous = cron.previousRelativeTo(current);
print("previous: $previous");
expect(cron.previousRelativeTo(current), DateTime.parse('2020-08-31 19:00:00'));
// Pass ✅
});
});
});
}Additional information
Flutter Version
Flutter 2.2.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f4abaa0735 (10 days ago) • 2021-07-01 12:46:11 -0700
Engine • revision 241c87ad80
Tools • Dart 2.13.4
Cronparse version
cronparse: ^0.1.1Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
