올해 크리스마스는 무슨 요일일까?
This file contains 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
/* 결과보기 : http://swiftstub.com/345157923 */ | |
enum Weekday: Int, CustomStringConvertible { | |
case Sun = 1 | |
case Mon, Tue, Wed, Thu, Fri, Sat | |
var description: String { | |
switch self { | |
case .Sun: return "Sunday" | |
case .Mon: return "Monday" | |
case .Tue: return "Tuesday" | |
case .Wed: return "Wedenesday" | |
case .Thu: return "Thursday" | |
case .Fri: return "Friday" | |
case .Sat: return "Saturday" | |
} | |
} | |
} | |
func whatIsTheDayOfThisChristmas() { | |
if let cal = NSCalendar(identifier: NSCalendarIdentifierGregorian), | |
case let thisYear: Int = | |
cal.components([.Year], fromDate:NSDate()).year { | |
let comps = NSDateComponents() | |
comps.year = thisYear | |
comps.month = 12 | |
comps.day = 25 | |
let christmas = cal.dateFromComponents(comps)! | |
let c = cal.components([.Day, .Weekday], fromDate:christmas) | |
print(Weekday(rawValue: c.weekday)!) | |
} | |
} | |
whatIsTheDayOfThisChristmas() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment