[+] Create function to create date from year, month, day, hour, min
This commit is contained in:
@@ -17,6 +17,19 @@ extension Date
|
|||||||
return f.string(from: self)
|
return f.string(from: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Constructor from components
|
||||||
|
static func create(_ year: Int, _ month: Int, _ day: Int, _ hour: Int, _ minute: Int) -> Date
|
||||||
|
{
|
||||||
|
var c = DateComponents()
|
||||||
|
c.year = year
|
||||||
|
c.month = month
|
||||||
|
c.day = day
|
||||||
|
c.hour = hour
|
||||||
|
c.minute = minute
|
||||||
|
let cal = Calendar(identifier: .gregorian)
|
||||||
|
return cal.date(from: c)!
|
||||||
|
}
|
||||||
|
|
||||||
/// Get year, month, day
|
/// Get year, month, day
|
||||||
func getYMD() -> (y: Int, m: Int, d: Int)
|
func getYMD() -> (y: Int, m: Int, d: Int)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user