adhan-dart
adhan-dart copied to clipboard
[in Some Location's adhan time is one hour Earlier]
For example in pakistan's almost every city is giving correct adhan time while in istanbul or some other location its time is one hour earlier than original. why?
The library returns time in your device's timezone? can ensure the result with matching timezone?
i am picking time from time zone with plugin. if you want code i can post it. Like if i want to pick azan time for Australia than i pass Australia time zone and lat lng. again it give me one hour earlier. but i check it for pakistan it gives me correct time....
How do you pass the timezone? (the library adhan-dart doesn't support passing timezone, it only support utcOffset passing).
tz.initializeTimeZones();
String timeZoneName = tzmap.latLngToTimezoneString(lat, lng);
var timeZoneLocation = tz.getLocation(timeZoneName);
final tz.TZDateTime now = tz.TZDateTime.now(timeZoneLocation);
var timeInUtc = DateTime.utc(1970, 1, 1);
var timeZone =
timeZoneLocation.timeZone(timeInUtc.millisecondsSinceEpoch);
print(timeZone.offset);
//offset conversion
print("MyOffset ${formattedTimeZoneOffset(now)}");
List<String> offsetSplitStrings = formattedTimeZoneOffset(now).split(":");
int offsetHours = int.parse(offsetSplitStrings[0]);
int offsetMin = int.parse(offsetSplitStrings[1]);
currentLocation = cityName;
setState(() {
final methodParams = selectedMethod != null
? selectedMethod.getParameters()
: adhan.CalculationMethod.tehran.getParameters();
methodParams.madhab =
selectedMazhab != null ? selectedMazhab : adhan.Madhab.hanafi;
methodParams.highLatitudeRule = selectedLatitude != null
? selectedLatitude
: adhan.HighLatitudeRule.middle_of_the_night;
prayerTimes = adhan.PrayerTimes(adhan.Coordinates(lat, lng),
adhan.DateComponents.from(now), methodParams,
utcOffset: Duration(hours: offsetHours, minutes: offsetMin));
calculatingPrayersTimings(
prayerTimes: prayerTimes, currentZoneTime: now, tag: "Manual");
});
For example in pakistan's almost every city is giving correct adhan time while in istanbul or some other location its time is one hour earlier than original. why?
Did you solve the problem? I'm getting the same issue, the times for Adhan is one hour early.
In parameters:
utcOffset: DateTime.now().timeZoneOffset + const Duration(hours: 1)
@HamadBangash353 can you retry using the TZDateTime? and do not pass utcOffset.
@HamadBangash353 ?