Skip to content

Instantly share code, notes, and snippets.

@akuraru
Last active April 13, 2018 08:32
Show Gist options
  • Save akuraru/f19d883536dd4e71d979f881d9d82a47 to your computer and use it in GitHub Desktop.
Save akuraru/f19d883536dd4e71d979f881d9d82a47 to your computer and use it in GitHub Desktop.
そのうち壊れるテスト書いた
import XCTest
class HeiseiTests: XCTestCase {
func test平成じゃない() {
let calendar = Calendar(identifier: .japanese)
let component = DateComponents(
calendar: calendar,
timeZone: nil,
era: 235, // 平成
year: 31,
month: 5, // この日から元号が変わる
day: 1
)
let date = component.date!
let year = calendar.dateComponents([.year], from: date).year
XCTAssert(year == 31)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment