plus method
Adds the specified Duration to this date-time.
The operation is timezone-aware and handles daylight saving time transitions correctly. If the addition crosses a DST boundary, the offset may change.
Example:
final zdt = ZonedDateTime.parse('2023-03-11T01:30:00-05:00[America/New_York]');
final later = zdt.plus(Duration(hours: 2));
// This crosses the DST transition (spring forward)
print('Before: $zdt'); // 01:30 EST
print('After: $later'); // 04:30 EDT (skips 02:30-03:30)
Implementation
ZonedDateTime plus(Duration duration) {
final newLocalDateTime = _localDateTime.plus(duration);
return ZonedDateTime.of(newLocalDateTime, _zone);
}