XPathDateTime.fromParts constructor

XPathDateTime.fromParts({
  1. int? year,
  2. int? month,
  3. int? day,
  4. int? hour,
  5. int? minute,
  6. int? second,
  7. int millisecond = 0,
  8. int microsecond = 0,
  9. int? timezoneOffsetMinutes,
  10. XPathType type = xsDateTime,
})

Creates a new XPathDateTime with named components filtered for the target type.

Implementation

factory fromParts({
  int? year,
  int? month,
  int? day,
  int? hour,
  int? minute,
  int? second,
  int millisecond = 0,
  int microsecond = 0,
  int? timezoneOffsetMinutes,
  XPathType type = xsDateTime,
}) {
  final hasYear =
      type != xsTime &&
      type != xsGMonthDay &&
      type != xsGMonth &&
      type != xsGDay;
  final hasMonth = type != xsTime && type != xsGYear && type != xsGDay;
  final hasDay =
      type != xsTime &&
      type != xsGYearMonth &&
      type != xsGYear &&
      type != xsGMonth;
  final hasTime = type.isSubtypeOf(xsDateTime) || type == xsTime;
  return XPathDateTime(
    hasYear ? year : null,
    hasMonth ? month : null,
    hasDay ? day : null,
    hasTime ? hour : null,
    hasTime ? minute : null,
    hasTime ? second : null,
    hasTime ? millisecond : 0,
    hasTime ? microsecond : 0,
    timezoneOffsetMinutes,
    type,
  );
}