Skip to content

Commit

Permalink
Fixed the TefilaRules class that had an issue with the isVeseinTalUma…
Browse files Browse the repository at this point in the history
…tarRecited method, also added tests
  • Loading branch information
Elyahu41 committed May 3, 2024
1 parent 3ee0b74 commit 1956a7c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion KosherSwiftNew.podspec
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 3 additions & 2 deletions Sources/KosherSwift/hebrewcalendar/TefilaRules.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public class TefilaRules {
*/
public func isTachanunRecitedMincha(jewishCalendar:JewishCalendar) -> Bool {
let tomorrow = JewishCalendar();
tomorrow.workingDate = jewishCalendar.workingDate
tomorrow.forward()

if (!tachanunRecitedMinchaAllYear
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down
14 changes: 14 additions & 0 deletions Tests/KosherSwiftTests/KosherSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1956a7c

Please sign in to comment.