Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSCalendar in Swift3

Tags:

xcode8

swift3

before Swift3, in a my project I used this function:

var components = (calendar as NSCalendar).components([.year, .monthSymbols, .firstWeekday, .timeZone, .hour, .minute], from: data_corrente)

Now I'm changing the project using swift 3 (xCode8 beta5) but I have this error:

Type 'NSCalendar.Unit has no member 'monthSymbol'

Can someone explain where is the problem and help me to solve it? I think is a migration problem

like image 788
Lorenzo Avatar asked Aug 13 '16 09:08

Lorenzo


1 Answers

In Swift3 with Xcode8 beta. You can use Calendar instead of NSCalendar as like this:

let calendar = Calendar.current
let component = calendar.dateComponents([.day,.month,.year], from: Date())
like image 126
technerd Avatar answered Nov 03 '22 00:11

technerd