Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
HamadBangash353 opened this issue May 27, 2021 · 8 comments
Open

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

HamadBangash353 opened this issue May 27, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@HamadBangash353
Copy link

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 HamadBangash353 added the bug Something isn't working label May 27, 2021
@iamriajul
Copy link
Owner

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

@HamadBangash353
Copy link
Author

HamadBangash353 commented May 27, 2021

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
Copy link
Owner

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

@HamadBangash353
Copy link
Author

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
Copy link

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
Copy link

JMApps commented Jan 31, 2023

In parameters:

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

@iamriajul
Copy link
Owner

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

@iamriajul
Copy link
Owner

image

image

image

@HamadBangash353 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants