durationToCron static method
Converts a Duration to a cron expression.
This method is useful if you want to generate a cron schedule from a Duration. Throws an ArgumentError if the duration is less than 1 second.
Example:
String cronExpr = WaCron.durationToCron(Duration(seconds: 10)); // "*/10 * * * * *"
Implementation
static String durationToCron(Duration duration) {
int sec = duration.inSeconds;
if (sec < 1) {
throw ArgumentError('Duration must be at least 1 sec.');
}
String cronExpression = '*/$sec * * * * *';
return cronExpression;
}