only method

DateTime only({
  1. int? year,
  2. int month = 1,
  3. int day = 1,
  4. int hour = 0,
  5. int minute = 0,
  6. int second = 0,
  7. int millisecond = 0,
  8. int microsecond = 0,
})

Returns DateTime with only information that is passed to the method. In contrast to DateTime.copyWith method, this method does not copy unspecified fields from the original DateTime.

Implementation

DateTime only({
  int? year,
  int month = 1,
  int day = 1,
  int hour = 0,
  int minute = 0,
  int second = 0,
  int millisecond = 0,
  int microsecond = 0,
}) {
  return (isUtc ? DateTime.utc : DateTime.new)(
    year ?? this.year,
    month,
    day,
    hour,
    minute,
    second,
    millisecond,
    microsecond,
  );
}