From 1956a7c8ba9e4e8c844809e7c2b45fceb6ea11e4 Mon Sep 17 00:00:00 2001 From: Elyahu Date: Fri, 3 May 2024 14:30:54 -0600 Subject: [PATCH] Fixed the TefilaRules class that had an issue with the isVeseinTalUmatarRecited method, also added tests --- KosherSwiftNew.podspec | 2 +- .../KosherSwift/hebrewcalendar/TefilaRules.swift | 5 +++-- Tests/KosherSwiftTests/KosherSwiftTests.swift | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/KosherSwiftNew.podspec b/KosherSwiftNew.podspec index 3619297..20cd842 100644 --- a/KosherSwiftNew.podspec +++ b/KosherSwiftNew.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |spec| spec.name = "KosherSwiftNew" - spec.version = "1.0.5" + spec.version = "1.0.6" spec.summary = "KosherJava Zmanim API / Library ported to Swift." spec.description = "This Zmanim library is an API for a specialized calendar that can calculate different astronomical times including sunrise and sunset and Jewish zmanim or religious times for prayers and other Jewish religious duties. diff --git a/Sources/KosherSwift/hebrewcalendar/TefilaRules.swift b/Sources/KosherSwift/hebrewcalendar/TefilaRules.swift index 447689f..5aebecc 100644 --- a/Sources/KosherSwift/hebrewcalendar/TefilaRules.swift +++ b/Sources/KosherSwift/hebrewcalendar/TefilaRules.swift @@ -180,6 +180,7 @@ public class TefilaRules { */ public func isTachanunRecitedMincha(jewishCalendar:JewishCalendar) -> Bool { let tomorrow = JewishCalendar(); + tomorrow.workingDate = jewishCalendar.workingDate tomorrow.forward() if (!tachanunRecitedMinchaAllYear @@ -222,7 +223,7 @@ public class TefilaRules { if (jewishCalendar.getDayOfWeek() == 7) { //Not recited on Friday night return false; } - if(jewishCalendar.getDayOfWeek() == 1) { // When starting on Sunday, it can be the start date or delayed from Shabbos + if (jewishCalendar.getDayOfWeek() == 1) { // When starting on Sunday, it can be the start date or delayed from Shabbos return jewishCalendar.getTekufasTishreiElapsedDays() == 48 || jewishCalendar.getTekufasTishreiElapsedDays() == 47; } else { return jewishCalendar.getTekufasTishreiElapsedDays() == 47; @@ -282,7 +283,7 @@ public class TefilaRules { if (jewishCalendar.getJewishMonth() == JewishCalendar.NISSAN && jewishCalendar.getJewishDayOfMonth() < 15) { return true; } - if (jewishCalendar.getJewishMonth() < JewishCalendar.CHESHVAN) { + if (jewishCalendar.getJewishMonth() >= JewishCalendar.NISSAN || jewishCalendar.getJewishMonth() == JewishCalendar.TISHREI) { return false; } if (jewishCalendar.getInIsrael()) { diff --git a/Tests/KosherSwiftTests/KosherSwiftTests.swift b/Tests/KosherSwiftTests/KosherSwiftTests.swift index b17a188..89e60a5 100644 --- a/Tests/KosherSwiftTests/KosherSwiftTests.swift +++ b/Tests/KosherSwiftTests/KosherSwiftTests.swift @@ -64,6 +64,20 @@ class KosherSwiftTests: XCTestCase { XCTAssertEqual(jewishCalendar.isPesach(), true) } + func testTefilaRules() { + jewishCalendar.setJewishDate(year: 5784, month: JewishCalendar.NISSAN, dayOfMonth: 14) + XCTAssertEqual(TefilaRules().isVeseinBerachaRecited(jewishCalendar: jewishCalendar), false) + + jewishCalendar.setJewishDate(year: 5784, month: JewishCalendar.NISSAN, dayOfMonth: 15) + XCTAssertEqual(TefilaRules().isVeseinBerachaRecited(jewishCalendar: jewishCalendar), true) + + jewishCalendar.setGregorianDate(year: 2023, month: 12, dayOfMonth: 5) + XCTAssertEqual(TefilaRules().isVeseinTalUmatarRecited(jewishCalendar: jewishCalendar), false) + + jewishCalendar.setGregorianDate(year: 2023, month: 12, dayOfMonth: 6) + XCTAssertEqual(TefilaRules().isVeseinTalUmatarRecited(jewishCalendar: jewishCalendar), true) + } + func testInternalHebrewCalendarMonths() { let arrayOfHebrewMonthsLeapYear = [8,9,10,11,12,13,1,2,3,4,5,6,7] jewishCalendar.setJewishDate(year: 5784, month: JewishCalendar.TISHREI, dayOfMonth: 1)//leap year