batoulapps / adhan-swift

High precision Islamic prayer time library for Swift
MIT License
182 stars 42 forks source link

It does not take in UTC offsets #74

Closed guccibase closed 2 years ago

guccibase commented 2 years ago

I have an app build with flutter that uses adhan-dart with adhan-java and adhan-swift for home widgets. Some high latitude areas require utc offsets which adhan-dart and adhan-java can take but adhan-swift does not seem to have that. Please make it be in sync with the others and take in a utc offset.

this is an example using utc offset in dart

  final newYork = Coordinates(35.7750, -78.6336);
  final nyUtcOffset = Duration(hours: -4);
  final nyDate = DateComponents(2015, 7, 12);
  final nyParams = CalculationMethod.north_america.getParameters();
  nyParams.madhab = Madhab.hanafi;
  final nyPrayerTimes = PrayerTimes(newYork, nyDate, nyParams, utcOffset: nyUtcOffset);
z3bi commented 2 years ago

Adhan Swift does not use a UTC offset intentionally. The prayer times it calculates are Date objects. It is up to you to use a DateFormatter that has the correct TimeZone set to display those dates. This is the correct way to handle dates and timezones in Swift.

Please see the Full Example in the README where a DateFormatter with a TimeZone set is used to display the prayer times.