iamriajul / adhan-dart

Adhan for Dart / Muslim Prayer Times Library. Now retrieving Prayer time in Dart easier than ever.
https://pub.dev/packages/adhan
MIT License
85 stars 40 forks source link

[in Some Location's adhan time is one hour Earlier] #27

Open HamadBangash353 opened 3 years ago

HamadBangash353 commented 3 years ago

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?

iamriajul commented 3 years ago

The library returns time in your device's timezone? can ensure the result with matching timezone?

HamadBangash353 commented 3 years ago

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....

iamriajul commented 3 years ago

How do you pass the timezone? (the library adhan-dart doesn't support passing timezone, it only support utcOffset passing).

HamadBangash353 commented 3 years ago
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");
        });
Umid0vic commented 2 years ago

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.

JMApps commented 1 year ago

In parameters:

utcOffset: DateTime.now().timeZoneOffset + const Duration(hours: 1)
iamriajul commented 10 months ago

@HamadBangash353 can you retry using the TZDateTime? and do not pass utcOffset.

iamriajul commented 10 months ago

image

image

image

@HamadBangash353 ?