combineDateAndTime function
Combines a Date and Time into a single DateTime instance. The resulting DateTime will be in UTC. Note that Date and Time instances are always in UTC internally, as they convert any input to UTC during construction.
This is useful when you need to combine separate date and time components into a single point in time.
Example:
final date = Date.today(); // Creates UTC date
final time = Time.now(); // Creates UTC time
final dateTime = combineDateAndTime(date, time); // Returns UTC DateTime
Implementation
DateTime combineDateAndTime(Date date, Time time) => DateTime.utc(
date.year,
date.month,
date.day,
time.hour,
time.minute,
time.second,
);