WP7: Dissecting we.Muslim app | Part 7 – Prayer Times Calculator

Given a Latitude Longitude Coordinate & UTC Offset, we can calculate Prayer Times in anywhere of the world…

Previous parts in this series:

  1. Part 1 – Wireframe
  2. Part 2 – Composites
  3. Part 3 – Icon Sizes
  4. Part 4 – Proper Splash Screen
  5. Part 5 - Get Current Latitude Longitude
  6. Parth 6 - Get Area Name from Latitude Longitude

There is already an excellent article on the calculation involved here http://praytimes.org/calculation , which I wouldn’t repeat.

While reading the article & converting the codes to C# 4.0 .NET, I noticed things that I hadn’t known before (or probably I was just ignorant):

  • All methods specify an angle for calculating Isha except the Makkah method. This method basically says that Isha is always 90 minutes after Magrib (or 120 minutes during Ramadhan). Obviously, this calculation might not be suitable for other parts of the world.
     
  • According to Imam Hanafi, Asr begins when the object’s shadow is twice the length of object + length of object at noon. So using this method, Asr will be later than other methods.

 

.NET Prayer Times Calculator

The .NET solution can be downloaded from https://github.com/zeddy/.NetPrayerTimes , since it’s too big and academic to discuss.

See below example on how to use it.

Note:

Currently you need to manually specify the UTC Offset (Timezone) and whether Daylight Savings Time is enabled. Future versions will automate this. Use the Watch feature of GitHub to stay be notified when new versions are checked in.

Console.WriteLine("Using Muslim World League Method");
Console.WriteLine("--- Location: Jakarta ----");
var calc1 = new Calculator();
var res1 = calc1.GetPrayerTimes(DateTime.Today, -6.17, 106.83, 0, +7);  // Jakarta
Console.WriteLine("Fajr: {0}", res1.Fajr);
Console.WriteLine("Dhuhur: {0}", res1.Dhuhur);
Console.WriteLine("Asr: {0}", res1.Asr);
Console.WriteLine("Magrib: {0}", res1.Magrib);
Console.WriteLine("Isha: {0}", res1.Isha);
Console.WriteLine();
Console.WriteLine("Using Makkah Method");
Console.WriteLine("--- Location: Dubai ----");
var calc2 = new Calculator(CalculationMethods.Makkah, AsrJuristics.Standard, HighLatitudeMethods.NightMiddle);
var res2 = calc2.GetPrayerTimes(DateTime.Today, 25.2522, 55.2800, 0, +4);   // Dubai
Console.WriteLine("Fajr: {0}", res2.Fajr);
Console.WriteLine("Dhuhur: {0}", res2.Dhuhur);
Console.WriteLine("Asr: {0}", res2.Asr);
Console.WriteLine("Magrib: {0}", res2.Magrib);
Console.WriteLine("Isha: {0}", res2.Isha);
Console.WriteLine();
Console.WriteLine("Using ISNA Method");
Console.WriteLine("--- Location: Redmond ----");
var calc3 = new Calculator(CalculationMethods.ISNA, AsrJuristics.Standard, HighLatitudeMethods.AngleBased);
var res3 = calc3.GetPrayerTimes(DateTime.Today, 47.6833, -122.1231, 0, -8);
Console.WriteLine("Fajr: {0}", res3.Fajr);
Console.WriteLine("Dhuhur: {0}", res3.Dhuhur);
Console.WriteLine("Asr: {0}", res3.Asr);
Console.WriteLine("Magrib: {0}", res3.Magrib);
Console.WriteLine("Isha: {0}", res3.Isha);
Console.WriteLine();
Console.ReadKey();

 

Hopefully this library is useful to fellow Muslims…

Share this post: | | | |
Published Friday, February 25, 2011 3:50 PM by zeddy

Comments

# Twitter Trackbacks for WP7: Dissecting we.Muslim app | Part 7 ??? Prayer Times Calculator - Z & his Startup [netindonesia.net] on Topsy.com

Pingback from  Twitter Trackbacks for                 WP7: Dissecting we.Muslim app | Part 7 ??? Prayer Times Calculator - Z & his Startup         [netindonesia.net]        on Topsy.com

Powered by Community Server (Commercial Edition), by Telligent Systems