cApplied method

DateTime cApplied(
  1. TimeOfDay time
)

Creates a new DateTime object with the applied TimeOfDay component.

This method combines the date part of the current DateTime instance with the hour and minute components from the provided time.

Example:

final date = DateTime.now();
final time = TimeOfDay(hour: 15, minute: 30);
final combinedDateTime = date.cApplied(time);
print(combinedDateTime); // Output: 2023-09-13 15:30:00.000

Implementation

DateTime cApplied(TimeOfDay time) {
  return DateTime(
    year,
    month,
    day,
    time.hour,
    time.minute,
  );
}