<commit_before>import Foundation

let calendarUnits: [NSCalendarUnit] = [
  NSCalendarUnit.CalendarUnitEra,
  NSCalendarUnit.CalendarUnitYear,
  NSCalendarUnit.CalendarUnitMonth,
  NSCalendarUnit.CalendarUnitDay,
  NSCalendarUnit.CalendarUnitHour,
  NSCalendarUnit.CalendarUnitMinute,
  NSCalendarUnit.CalendarUnitSecond,
  NSCalendarUnit.CalendarUnitNanosecond,
  NSCalendarUnit.CalendarUnitWeekday,
  NSCalendarUnit.CalendarUnitWeekdayOrdinal,
  NSCalendarUnit.CalendarUnitQuarter,
  NSCalendarUnit.CalendarUnitWeekOfMonth,
  NSCalendarUnit.CalendarUnitWeekOfYear,
  NSCalendarUnit.CalendarUnitYearForWeekOfYear
]

public func +(left: NSDateComponents, right: NSDateComponents) -> NSDateComponents {
  map(calendarUnits) { unit -> () in
    let leftValue = left.valueForComponent(unit)
    let rightValue = right.valueForComponent(unit)
    var value: Int

    if leftValue != Int(NSDateComponentUndefined) && rightValue != Int(NSDateComponentUndefined) {
      value = leftValue + rightValue
    } else if leftValue == Int(NSDateComponentUndefined) && rightValue != Int(NSDateComponentUndefined) {
      value = rightValue
    } else {
      value = leftValue
    }

    left.setValue(value, forComponent: unit)
  }
  return left
}

public func +(date: NSDate, components: NSDateComponents) -> NSDate {
  let calendar = components.calendar ?? NSCalendar.autoupdatingCurrentCalendar()
  return calendar.dateByAddingComponents(components, toDate: date, options: .allZeros) ?? date
}

public prefix func +(components: NSDateComponents) -> NSDateComponents {
  map(calendarUnits) { unit -> () in
    let value = components.valueForComponent(unit)
    if value != Int(NSDateComponentUndefined) {
      components.setValue(abs(value), forComponent:unit)
    }
  }
  return components
}

public func -(left: NSDateComponents, right: NSDateComponents) -> NSDateComponents {
  map(calendarUnits) { unit -> () in
    let leftValue = left.valueForComponent(unit)
    let rightValue = right.valueForComponent(unit)
    var value: Int

    if leftValue != Int(NSDateComponentUndefined) && rightValue != Int(NSDateComponentUndefined) {
      value = leftValue - rightValue
    } else if leftValue == Int(NSDateComponentUndefined) && rightValue != Int(NSDateComponentUndefined) {
      value = -rightValue
    } else {
      value = leftValue
    }

    left.setValue(value, forComponent: unit)
  }
  return left
}

public func-(date: NSDate, components: NSDateComponents) -> NSDate {
  let calendar = components.calendar ?? NSCalendar.autoupdatingCurrentCalendar()
  return calendar.dateByAddingComponents(-components, toDate: date, options: .allZeros) ?? date
}<commit_msg>Consistent naming for operator arguments<commit_after>import Foundation

let calendarUnits: [NSCalendarUnit] = [
  NSCalendarUnit.CalendarUnitEra,
  NSCalendarUnit.CalendarUnitYear,
  NSCalendarUnit.CalendarUnitMonth,
  NSCalendarUnit.CalendarUnitDay,
  NSCalendarUnit.CalendarUnitHour,
  NSCalendarUnit.CalendarUnitMinute,
  NSCalendarUnit.CalendarUnitSecond,
  NSCalendarUnit.CalendarUnitNanosecond,
  NSCalendarUnit.CalendarUnitWeekday,
  NSCalendarUnit.CalendarUnitWeekdayOrdinal,
  NSCalendarUnit.CalendarUnitQuarter,
  NSCalendarUnit.CalendarUnitWeekOfMonth,
  NSCalendarUnit.CalendarUnitWeekOfYear,
  NSCalendarUnit.CalendarUnitYearForWeekOfYear
]

public func +(lhs: NSDateComponents, rhs: NSDateComponents) -> NSDateComponents {
  map(calendarUnits) { unit -> () in
    let leftValue = lhs.valueForComponent(unit)
    let rightValue = rhs.valueForComponent(unit)
    var value: Int

    if leftValue != Int(NSDateComponentUndefined) && rightValue != Int(NSDateComponentUndefined) {
      value = leftValue + rightValue
    } else if leftValue == Int(NSDateComponentUndefined) && rightValue != Int(NSDateComponentUndefined) {
      value = rightValue
    } else {
      value = leftValue
    }

    lhs.setValue(value, forComponent: unit)
  }
  return lhs
}

public func +(date: NSDate, components: NSDateComponents) -> NSDate {
  let calendar = components.calendar ?? NSCalendar.autoupdatingCurrentCalendar()
  return calendar.dateByAddingComponents(components, toDate: date, options: .allZeros) ?? date
}

public prefix func +(components: NSDateComponents) -> NSDateComponents {
  map(calendarUnits) { unit -> () in
    let value = components.valueForComponent(unit)
    if value != Int(NSDateComponentUndefined) {
      components.setValue(abs(value), forComponent:unit)
    }
  }
  return components
}

public func -(lhs: NSDateComponents, rhs: NSDateComponents) -> NSDateComponents {
  map(calendarUnits) { unit -> () in
    let leftValue = lhs.valueForComponent(unit)
    let rightValue = rhs.valueForComponent(unit)
    var value: Int

    if leftValue != Int(NSDateComponentUndefined) && rightValue != Int(NSDateComponentUndefined) {
      value = leftValue - rightValue
    } else if leftValue == Int(NSDateComponentUndefined) && rightValue != Int(NSDateComponentUndefined) {
      value = -rightValue
    } else {
      value = leftValue
    }

    lhs.setValue(value, forComponent: unit)
  }
  return lhs
}

public func-(date: NSDate, components: NSDateComponents) -> NSDate {
  let calendar = components.calendar ?? NSCalendar.autoupdatingCurrentCalendar()
  return calendar.dateByAddingComponents(-components, toDate: date, options: .allZeros) ?? date
}
{'fraction_non_alphanumeric': 0.09331084879145587, 'fraction_numerical': 0.0, 'mean_word_length': 4.783315276273023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3914018', 'n_tokens_mistral': 1605, 'n_tokens_neox': 1640, 'n_words': 322}