batoulapps / adhan-swift

High precision Islamic prayer time library for Swift
MIT License
182 stars 42 forks source link

Guideline for SwiftUI usage #38

Closed ghost closed 4 years ago

ghost commented 4 years ago

I'm trying to add prayer time on my xcode project with SwiftUI. I successfully added the Library but I have many issues loading the properties following the guideline. Is it possible to have a clarification on how to import prayer time on SwiftUI based on users location and date?

Thanks

z3bi commented 4 years ago

Here's an example of using Adhan in SwiftUI https://gist.github.com/z3bi/7651f59bdad966820a8b2d307e5596f9

ghost commented 4 years ago

Thanks for that, it works but if I put latitude and longitude of my place in Europe the timings are not correct, is there something I missed? By the way I find that tricky how it works and I would really be grateful if you could help me out with that. I'm making a Islam app and it's almost done except for prayer times I really hope you could help me Inshallah

Il giorno mer 2 set 2020 alle ore 00:00 Ameir Al-Zoubi < notifications@github.com> ha scritto:

Here's an example of using Adhan in SwiftUI https://gist.github.com/z3bi/7651f59bdad966820a8b2d307e5596f9

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/batoulapps/adhan-swift/issues/38#issuecomment-685156406, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ2WIKCFZ4N7RDMFU2KFYS3SDVVG7ANCNFSM4QSHJMCQ .

z3bi commented 4 years ago

@Myhrs95 in addition to changing the coordinates, you will need to modify the rest of the params to give correct values for that location. All of these values are listed here https://github.com/batoulapps/adhan-swift/blob/master/METHODS.md

ghost commented 4 years ago

I see but the problem is that if I put Bologna latitude and longitude (where I live), I get fajr time at 8 pm and even if I change fajr and isha degree it's not working. It should be close to 4 am at least not 8 pm.

Il giorno mer 2 set 2020 alle ore 16:55 Ameir Al-Zoubi < notifications@github.com> ha scritto:

@Myhrs95 https://github.com/Myhrs95 in addition to changing the coordinates, you will need to modify the rest of the params to give correct values for that location. All of these values are listed here https://github.com/batoulapps/adhan-swift/blob/master/METHODS.md

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/batoulapps/adhan-swift/issues/38#issuecomment-685790683, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ2WIKDOD4AYZMPGMWJELJ3SDZMFHANCNFSM4QSHJMCQ .

z3bi commented 4 years ago

@Myhrs95 that sounds like a time zone issue. Time zones are going to be entirely the job of the date formatter. In the gist I posted you'll see this at the top

private let dateFormatter: DateFormatter = {
    let dateFormatter = DateFormatter()
    dateFormatter.dateStyle = .none
    dateFormatter.timeStyle = .medium
    return dateFormatter
}()

This will create a date formatter in the current timezone of the device you're running on. In the README it mentions needing to use the correct timezone in the formatter. https://github.com/batoulapps/adhan-swift#prayer-times

ghost commented 4 years ago

I tried changing timezone with different abbreviations like UTC, WET, CET but I always get the same result. I know I might stress you but I really need to figure out how to make it work

Il giorno mer 2 set 2020 alle ore 18:54 Ameir Al-Zoubi < notifications@github.com> ha scritto:

@Myhrs95 https://github.com/Myhrs95 thats going to be entirely the job of the date formatter. In the gist I posted you'll see this at the top

private let dateFormatter: DateFormatter = { let dateFormatter = DateFormatter() dateFormatter.dateStyle = .none dateFormatter.timeStyle = .medium return dateFormatter }()

This will create a date formatter in the current timezone of the device you're running on. In the README it mentions needing to use the correct timezone in the formatter. https://github.com/batoulapps/adhan-swift#prayer-times

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/batoulapps/adhan-swift/issues/38#issuecomment-685865314, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ2WIKHYFRWP2DCBMTLMDEDSDZ2D7ANCNFSM4QSHJMCQ .

z3bi commented 4 years ago

@Myhrs95 I am being as helpful as I can, but being rude and asking people to solve your own coding problems is not really a great strategy.

It sounds like you aren't initializing a timezone correctly. I would recommend reading the documentation here https://developer.apple.com/documentation/foundation/nstimezone you should initialize a timezone with a correct TZDB identifier, you can find a list of them here https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

ghost commented 4 years ago

I didn't meant to be rude at all, I also apologized if I might be stressful for asking too many things. Unfortunately I'm not a master of Swift and most of the things are just new to me but anyway, you're the only one who's answering me and I really thank you for that. I'm just kinda upset of myself cause I've been working on my app for almost 8 months and now I see that the last thing I have to add might take months for me to implement since I have to study it from scratch. I'm sorry if you felt that I was rude but I wasn't

I will look at the documentation and figure it out Inshallah Thanks for your time

Il giorno mer 2 set 2020 alle ore 23:14 Ameir Al-Zoubi < notifications@github.com> ha scritto:

@Myhrs95 https://github.com/Myhrs95 I am being as helpful as I can, but being rude and asking people to solve your own coding problems is not really a great strategy.

It sounds like you aren't initializing a timezone correctly. I would recommend reading the documentation here https://developer.apple.com/documentation/foundation/nstimezone you should initialize a timezone with a correct TZDB identifier, you can find a list of them here https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/batoulapps/adhan-swift/issues/38#issuecomment-686006201, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ2WIKHGPWZJMI73WTA3PMDSD2YTBANCNFSM4QSHJMCQ .

z3bi commented 4 years ago

No problem. Good luck with your project.