Skip to content

Commit

Permalink
Add international workers day, with aliases to may day and labor day
Browse files Browse the repository at this point in the history
  • Loading branch information
ffried committed May 31, 2023
1 parent 0de4271 commit 6ccc447
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Sources/SwiftyHolidays/Gregorian/GregorianCalculator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions Tests/SwiftyHolidaysTests/Gregorian/GregorianCalculatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit 6ccc447

Please sign in to comment.