adhan-dart icon indicating copy to clipboard operation
adhan-dart copied to clipboard

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

Open HamadBangash353 opened this issue 3 years ago • 8 comments

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?

HamadBangash353 avatar May 27 '21 07:05 HamadBangash353

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

iamriajul avatar May 27 '21 08:05 iamriajul

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

HamadBangash353 avatar May 27 '21 09:05 HamadBangash353

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

iamriajul avatar Jun 07 '21 06:06 iamriajul

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");
        });

HamadBangash353 avatar Jun 10 '21 05:06 HamadBangash353

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.

Umid0vic avatar Jan 21 '22 19:01 Umid0vic

In parameters:

utcOffset: DateTime.now().timeZoneOffset + const Duration(hours: 1)

JMApps avatar Jan 31 '23 04:01 JMApps

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

iamriajul avatar Sep 22 '23 14:09 iamriajul

image

image

image

@HamadBangash353 ?

iamriajul avatar Sep 22 '23 14:09 iamriajul