copyWith method
Returns a copy of this DateTime with the given fields replaced.
DateTime(2024, 3, 15).copyWith(month: 6) // DateTime(2024, 6, 15)
Implementation
DateTime copyWith({
int? year,
int? month,
int? day,
int? hour,
int? minute,
int? second,
int? millisecond,
int? microsecond,
}) =>
DateTime(
year ?? this.year,
month ?? this.month,
day ?? this.day,
hour ?? this.hour,
minute ?? this.minute,
second ?? this.second,
millisecond ?? this.millisecond,
microsecond ?? this.microsecond,
);