2016-12-25 26 views

答えて

1

跳躍するために設定した場合、当該月の最初の日は、有効な日付であるかどうかをチェックすることができます:

func isLeap(month: Int, year: Int, era: Int, calendar: Calendar) -> Bool { 
    var components = DateComponents() 
    components.era = era 
    components.year = year 
    components.month = month 
    components.day = 1 
    components.isLeapMonth = true 

    return components.isValidDate(in: calendar) 
} 

// The Chinese year that begins in 2017 
isLeap(month: 5, year: 34, era: 78, calendar: Calendar(identifier: .chinese)) // false 
isLeap(month: 6, year: 34, era: 78, calendar: Calendar(identifier: .chinese)) // true 

// The Chinese year that begins in 2020 
isLeap(month: 3, year: 37, era: 78, calendar: Calendar(identifier: .chinese)) // false 
isLeap(month: 4, year: 37, era: 78, calendar: Calendar(identifier: .chinese)) // true 

this listによると、閏月使用し、いくつかのカレンダーシステムがあります日付修正機構として使用します。中国のカレンダーは私がもっとよく知っているものです。 list of leap months in the Chinese calendar

との相互参照ができます
関連する問題