SwiftDateTimeExtensions
SwiftDateTimeExtensions copied to clipboard
Build fails on XCode 6.2
Hi, I'm trying to build the timeDateExtensions.swift with xcode 6.2 for iOS 8.2 and getting a lot of conversion errors:
func combineComponents(left: NSDateComponents, right: NSDateComponents, multiplier: Int) -> NSDateComponents { let comps = NSDateComponents() comps.second = ((left.second != NSDateComponentUndefined ? left.second : 0) + (right.second != NSDateComponentUndefined ? right.second : 0) * multiplier) ... <'Int' is not convertible to 'NSDateComponents'>
Any idea what's wrong? As far as I see it NSDateComponents.secont still is an int.
by the way: love how this extensions make working with dates more readable!
Armin
obviously NSDateComponentUndefined is a UInt, thereas NSDateComponents are int. Don't know what Apple thought when they did that... My solution would be
let undefined = Int(NSUndefinedDateComponent) ... comps.second = ((left.second != undefined ? left.second : 0) + (right.second != undefined ? right.second : 0) * multiplier)
@ArminGrau, Maybe you would like to see the improved version? See Datify.