getUtcTimeFromLocal method
Converts the current DateTime to UTC and adds the specified offset.
Args: offset (double): The offset to add, in hours.
Returns: DateTime?: A new DateTime object with the added offset, or null if the offset is 0.
Implementation
DateTime? getUtcTimeFromLocal(double offset) {
if (offset == 0) {
return this;
}
final int hours = offset.floor();
final int minutes = ((offset - hours) * 60).round();
return toUtc().add(Duration(hours: hours, minutes: minutes));
}