Skip to content

Commit

Permalink
fix some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Elyahu41 committed Dec 27, 2023
1 parent 1dd4401 commit fd8c6ea
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 55 deletions.
86 changes: 33 additions & 53 deletions Sources/KosherSwift/ComplexZmanimCalendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ public class ComplexZmanimCalendar : ZmanimCalendar {
*
*/
public func getMisheyakir66MinutesZmanit() -> Date? {
let shaahZmanit = getShaahZmanis72MinutesZmanis()
let shaahZmanit = getShaahZmanisGra()
let dakahZmanit = shaahZmanit / 60
return ComplexZmanimCalendar.getTimeOffset(time: getAlos72Zmanis(), offset: 6 * Double(dakahZmanit))
}
Expand All @@ -1198,7 +1198,7 @@ public class ComplexZmanimCalendar : ZmanimCalendar {
*
*/
public func getMisheyakir60MinutesZmanit() -> Date? {
let shaahZmanit = getShaahZmanis72MinutesZmanis()
let shaahZmanit = getShaahZmanisGra()
let dakahZmanit = shaahZmanit / 60
return ComplexZmanimCalendar.getTimeOffset(time: getAlos72Zmanis(), offset: 12 * Double(dakahZmanit))
}
Expand Down Expand Up @@ -4617,19 +4617,15 @@ public class ComplexZmanimCalendar : ZmanimCalendar {
calendar.timeZone = geoLocation.timeZone
let temp = workingDate
workingDate = calendar.date(from: DateComponents(year: calendar.component(.year, from: workingDate), month: 3, day: 17))!
let alotBy16Degrees = getSunriseOffsetByDegrees(offsetZenith:ComplexZmanimCalendar.GEOMETRIC_ZENITH + 16.04)
let shaahZmanit = getShaahZmanisGra()

if (shaahZmanit == .min) {

let percentage = getPercentOfShaahZmanisFromDegrees(degrees: 16.04, sunset: false)
if (percentage == (-Double.greatestFiniteMagnitude)) {
return nil;
}
let numberOfSeconds = ((getSeaLevelSunrise()!.timeIntervalSince1970 - alotBy16Degrees!.timeIntervalSince1970))
workingDate = temp//reset

let dakahZmanit = shaahZmanit / 60
let secondsZmanit = dakahZmanit / 60

return ComplexZmanimCalendar.getTimeOffset(time: getSeaLevelSunrise(), offset: -(numberOfSeconds * Double(secondsZmanit)))

let shaahZmanit = Double(getTemporalHour(startOfDay: getSeaLevelSunrise(), endOfDay: getSeaLevelSunset()));
return ComplexZmanimCalendar.getTimeOffset(time: getSeaLevelSunrise(), offset: -(percentage * shaahZmanit));
}

/**
Expand All @@ -4643,19 +4639,15 @@ public class ComplexZmanimCalendar : ZmanimCalendar {
calendar.timeZone = geoLocation.timeZone
let temp = workingDate
workingDate = calendar.date(from: DateComponents(year: calendar.component(.year, from: workingDate), month: 3, day: 17))!
let alotBy16Degrees = getSunriseOffsetByDegrees(offsetZenith:ComplexZmanimCalendar.GEOMETRIC_ZENITH + 16.04)
let shaahZmanit = getShaahZmanisGra()

if (shaahZmanit == .min) {

let percentage = getPercentOfShaahZmanisFromDegrees(degrees: 16.04, sunset: false)
if (percentage == (-Double.greatestFiniteMagnitude)) {
return nil;
}
let numberOfSeconds = ((getSeaLevelSunrise()!.timeIntervalSince1970 - alotBy16Degrees!.timeIntervalSince1970))
workingDate = temp//reset

let dakahZmanit = shaahZmanit / 60
let secondsZmanit = dakahZmanit / 60

return ComplexZmanimCalendar.getTimeOffset(time: getSeaLevelSunrise(), offset: -(numberOfSeconds * Double(secondsZmanit) * 5 / 6))

let shaahZmanit = Double(getTemporalHour(startOfDay: getSeaLevelSunrise(), endOfDay: getSeaLevelSunset()));
return ComplexZmanimCalendar.getTimeOffset(time: getSeaLevelSunrise(), offset: -(percentage * shaahZmanit) * 5 / 6);
}

// These methods are similar to the ones in the base class, but they use the Amudei Horaah zmanim instead of the regular zmanim
Expand Down Expand Up @@ -4684,59 +4676,47 @@ public class ComplexZmanimCalendar : ZmanimCalendar {
calendar.timeZone = geoLocation.timeZone
let temp = workingDate
workingDate = calendar.date(from: DateComponents(year: calendar.component(.year, from: workingDate), month: 3, day: 17))!
let tzaitGeonimInDegrees = getSunsetOffsetByDegrees(offsetZenith:ComplexZmanimCalendar.GEOMETRIC_ZENITH + 3.77)
let shaahZmanit = getShaahZmanisGra()

if (shaahZmanit == .min) {

let percentage = getPercentOfShaahZmanisFromDegrees(degrees: 3.77, sunset: true)
if (percentage == (-Double.greatestFiniteMagnitude)) {
return nil;
}
let numberOfSeconds = (tzaitGeonimInDegrees!.timeIntervalSince1970 - getSeaLevelSunset()!.timeIntervalSince1970)
workingDate = temp//reset

let dakahZmanit = shaahZmanit / 60
let secondsZmanit = dakahZmanit / 60

return ComplexZmanimCalendar.getTimeOffset(time: getSeaLevelSunset(), offset: numberOfSeconds * Double(secondsZmanit))

let shaahZmanit = Double(getTemporalHour(startOfDay: getSeaLevelSunrise(), endOfDay: getSeaLevelSunset()));
return ComplexZmanimCalendar.getTimeOffset(time: getSeaLevelSunset(), offset: percentage * shaahZmanit);
}

public func getTzaisAmudeiHoraahLChumra() -> Date? {
var calendar = Calendar.current
calendar.timeZone = geoLocation.timeZone
let temp = workingDate
workingDate = calendar.date(from: DateComponents(year: calendar.component(.year, from: workingDate), month: 3, day: 17))!
let tzaitGeonimInDegrees = getSunsetOffsetByDegrees(offsetZenith:ComplexZmanimCalendar.GEOMETRIC_ZENITH + 5.135)
let shaahZmanit = getShaahZmanisGra()

if (shaahZmanit == .min) {

let percentage = getPercentOfShaahZmanisFromDegrees(degrees: 5.135, sunset: true)
if (percentage == (-Double.greatestFiniteMagnitude)) {
return nil;
}
let numberOfSeconds = (tzaitGeonimInDegrees!.timeIntervalSince1970 - getSeaLevelSunset()!.timeIntervalSince1970)
workingDate = temp//reset

let dakahZmanit = shaahZmanit / 60
let secondsZmanit = dakahZmanit / 60

return ComplexZmanimCalendar.getTimeOffset(time: getSeaLevelSunset(), offset: numberOfSeconds * Double(secondsZmanit))

let shaahZmanit = Double(getTemporalHour(startOfDay: getSeaLevelSunrise(), endOfDay: getSeaLevelSunset()));
return ComplexZmanimCalendar.getTimeOffset(time: getSeaLevelSunset(), offset: percentage * shaahZmanit);
}

public func getTzais72ZmanisAmudeiHoraah() -> Date? {
var calendar = Calendar.current
calendar.timeZone = geoLocation.timeZone
let temp = workingDate
workingDate = calendar.date(from: DateComponents(year: calendar.component(.year, from: workingDate), month: 3, day: 17))!
let tzaitRTInDegrees = getSunsetOffsetByDegrees(offsetZenith:ComplexZmanimCalendar.GEOMETRIC_ZENITH + 16.01)
let shaahZmanit = getShaahZmanisGra()

if (shaahZmanit == .min) {

let percentage = getPercentOfShaahZmanisFromDegrees(degrees: 16.01, sunset: true)
if (percentage == (-Double.greatestFiniteMagnitude)) {
return nil;
}
let numberOfSeconds = (tzaitRTInDegrees!.timeIntervalSince1970 - getSeaLevelSunset()!.timeIntervalSince1970)
workingDate = temp//reset

let dakahZmanit = shaahZmanit / 60
let secondsZmanit = dakahZmanit / 60

return ComplexZmanimCalendar.getTimeOffset(time: getSeaLevelSunset(), offset: numberOfSeconds * Double(secondsZmanit))

let shaahZmanit = Double(getTemporalHour(startOfDay: getSeaLevelSunrise(), endOfDay: getSeaLevelSunset()));
return ComplexZmanimCalendar.getTimeOffset(time: getSeaLevelSunset(), offset: percentage * shaahZmanit);
}

public func getTzaisShabbatAmudeiHoraah() -> Date? {
Expand All @@ -4762,7 +4742,7 @@ public class ComplexZmanimCalendar : ZmanimCalendar {
This is only for display purposes, it should not be used to calculate zmanim.
- Returns: The earlier of ``getTzais72()`` or ``getTzais72ZmanitAmudeiHoraah()``
*/
public func getTzaisZmanitAmudeiHoraahLkulah() -> Date? {
public func getTzais72ZmanisAmudeiHoraahLkulah() -> Date? {
if getTzais72() == nil || getTzais72ZmanisAmudeiHoraah() == nil {
return nil
}
Expand Down
6 changes: 6 additions & 0 deletions Sources/KosherSwift/hebrewcalendar/HebrewDateFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ public class HebrewDateFormatter {
JewishCalendar.Parsha.CHAZON: "חזון",
JewishCalendar.Parsha.NACHAMU: "נחמו"
]

if (longWeekFormat) {
weekFormat.dateFormat = "EEEE";
} else {
weekFormat.dateFormat = "EEE";
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Tests/KosherSwiftTests/KosherSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ class KosherSwiftTests: XCTestCase {
let calculator = ComplexZmanimCalendar(location: geoLocation)
let format = DateFormatter()
format.timeStyle = .full
print(format.string(from: calculator.getSeaLevelSunrise()!))
print(format.string(from: calculator.getSeaLevelSunset()!))
print(format.string(from: calculator.getTzais72ZmanisAmudeiHoraah()!))
print(format.string(from: calculator.getTzaisShabbatAmudeiHoraah()!))
}

// func testPerformanceExample() throws {
Expand Down

0 comments on commit fd8c6ea

Please sign in to comment.