Created
September 18, 2015 15:08
-
-
Save masters3d/b90a99aac6b923add0ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Darwin | |
extension tm{ | |
var year:Int32 { return tm_year + 1900 } | |
var month:Int32 { return tm_mon + 1 } | |
var day:Int32 { return tm_mday } | |
var time:(hour:Int32, mins:Int32, secs:Int32){ | |
return (hour: tm_hour, mins: tm_min, secs:tm_sec) | |
} | |
init(year:Int32, month:Int32, day:Int32, hour:Int32 = 0, mins:Int32 = 0, secs:Int32 = 0){ | |
self.init() | |
self.tm_year = year - 1900 | |
self.tm_mon = month - 1 | |
self.tm_mday = day | |
self.tm_hour = hour | |
self.tm_min = mins | |
self.tm_sec = secs | |
} | |
mutating func dateByAddingSeconds(seconds:Int) -> tm { | |
var d1 = timegm(&self) + seconds | |
return gmtime(&d1).memory | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment