offsetDateTime method
Implementation
DateTime offsetDateTime(TimeUnit offsetType, int offsetValue) {
Duration offsetDuration;
switch (offsetType) {
case TimeUnit.year:
offsetDuration = Duration(days: offsetValue * 366);
break;
case TimeUnit.month:
offsetDuration = Duration(days: offsetValue * 30);
break;
case TimeUnit.day:
offsetDuration = Duration(days: offsetValue);
break;
case TimeUnit.hour:
offsetDuration = Duration(hours: offsetValue);
break;
case TimeUnit.minute:
offsetDuration = Duration(minutes: offsetValue);
break;
case TimeUnit.second:
offsetDuration = Duration(seconds: offsetValue);
break;
default:
throw ArgumentError('Invalid offset type: $offsetType');
}
return add(offsetDuration);
}