nextInstanceOfTime method

TZDateTime nextInstanceOfTime(
  1. Time time
)

Implementation

tz.TZDateTime nextInstanceOfTime(Time time) {
  final DateTime now = DateTime.now();

  DateTime scheduledDate = DateTime(
    now.year,
    now.month,
    now.day,
    time.hour,
    time.minute,
    time.second,
  );

  if (scheduledDate.isBefore(now)) {
    scheduledDate = scheduledDate.add(const Duration(days: 1));
  }

  return tz.TZDateTime.from(scheduledDate, tz.local);
}