Skip to content

Instantly share code, notes, and snippets.

@sooop
Created November 27, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sooop/a73496bbfc7dfb7d3359 to your computer and use it in GitHub Desktop.
Save sooop/a73496bbfc7dfb7d3359 to your computer and use it in GitHub Desktop.
올해 크리스마스는 무슨 요일일까?
/* 결과보기 : 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