diff --git a/Sources/SwiftyHolidays/Gregorian/GregorianCalculator.swift b/Sources/SwiftyHolidays/Gregorian/GregorianCalculator.swift index bd4763f..6277d4c 100644 --- a/Sources/SwiftyHolidays/Gregorian/GregorianCalculator.swift +++ b/Sources/SwiftyHolidays/Gregorian/GregorianCalculator.swift @@ -265,6 +265,35 @@ public struct GregorianCalculator: Calculator { date(for: .easterMonday, forYear: year, calculation: calculateEasterMonday) } + /// Calculates the date of international workers day for a given year. + /// + /// - Parameter year: The year for which to calculate international workers day. + /// - Returns: The date of international workers day in the given year. + @inlinable + public func internationalWorkersDay(forYear year: Int) -> TimelessDate { + .init(day: 1, month: 5, year: year) + } + + /// Calculates the date of labor day for a given year. It's an alias for the international workers day. + /// + /// - Parameter year: The year for which to calculate labor day. + /// - Returns: The date of labor day in the given year. + /// - SeeAlso: ``internationalWorkersDay(forYear:)`` + @inlinable + public func laborDay(forYear year: Int) -> TimelessDate { + internationalWorkersDay(forYear: year) + } + + /// Calculates the date of May day for a given year. It's an alias for the international workers day. + /// + /// - Parameter year: The year for which to calculate May day. + /// - Returns: The date of May day in the given year. + /// - SeeAlso: ``internationalWorkersDay(forYear:)`` + @inlinable + public func mayDay(forYear year: Int) -> TimelessDate { + internationalWorkersDay(forYear: year) + } + /// Calculates the date of the ascension day for a given year. /// - Parameter year: The year for which to calculate the ascension day. /// - Returns: The date of the ascension day in the given year. diff --git a/Tests/SwiftyHolidaysTests/Gregorian/GregorianCalculatorTests.swift b/Tests/SwiftyHolidaysTests/Gregorian/GregorianCalculatorTests.swift index d341f7f..0386fac 100644 --- a/Tests/SwiftyHolidaysTests/Gregorian/GregorianCalculatorTests.swift +++ b/Tests/SwiftyHolidaysTests/Gregorian/GregorianCalculatorTests.swift @@ -41,6 +41,18 @@ final class GregorianCalculatorTests: XCTestCase { XCTAssertEqual(calculator.easterMonday(forYear: 2019), TimelessDate(day: 22, month: 4, year: 2019)) } + func testInternationalWorkersDay() { + XCTAssertEqual(calculator.internationalWorkersDay(forYear: 2019), TimelessDate(day: 1, month: 5, year: 2019)) + } + + func testLaborDay() { + XCTAssertEqual(calculator.laborDay(forYear: 2019), calculator.internationalWorkersDay(forYear: 2019)) + } + + func testMayDay() { + XCTAssertEqual(calculator.mayDay(forYear: 2019), calculator.internationalWorkersDay(forYear: 2019)) + } + func testAscensionDay() { XCTAssertEqual(calculator.ascensionDay(forYear: 2019), TimelessDate(day: 30, month: 5, year: 2019)) }