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
86 stars 41 forks source link

Even with offset value some location have one hour difference like new york #23

Closed HamadBangash353 closed 3 years ago

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

        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(milliseconds: timeZone.offset));

This is how i calculate prayer times but in new york it has one hour deff, and for newyork offset value is -18000000 in millis.

iamriajul commented 3 years ago

You don't need to pass utcOffset if your device (in your case android) is already running in your desired timezone.

iamriajul commented 3 years ago

might be duplicate of #25