private async void CalculatePrayTimes() { var currentLocation = await this.GetcurrentLocation(); if (currentLocation != null) { var calc = new PrayerTimesCalculator(currentLocation.Latitude, currentLocation.Longitude) { CalculationMethod = CalculationMethods.Egypt, AsrJurusticMethod = AsrJuristicMethods.Shafii }; var local = currentLocation.Timestamp.ToLocalTime(); this.Heading = currentLocation.Heading; var times = calc.GetPrayerTimes(local); var timesDate = times.Date.Date; this.Date = timesDate.ToString("D"); this.Fajr = timesDate.Add(times.Fajr).ToString("hh:mm tt"); this.Sunrise = timesDate.Add(times.Sunrise).ToString("hh:mm tt"); this.Dhuhr = timesDate.Add(times.Dhuhr).ToString("hh:mm tt"); this.Asr = timesDate.Add(times.Asr).ToString("hh:mm tt"); this.Maghrib = timesDate.Add(times.Maghrib).ToString("hh:mm tt"); this.Sunset = timesDate.Add(times.Sunset).ToString("hh:mm tt"); this.Isha = timesDate.Add(times.Isha).ToString("hh:mm tt"); } }
public void TestTimesForYear() { PrayerTimesCalculator calc = new PrayerTimesCalculator(47.660918, -122.136371); calc.CalculationMethod = CalculationMethods.ISNA; calc.AsrJurusticMethod = AsrJuristicMethods.Shafii; var times = new Times[365]; for (int i = 0; i < 365; i ++) { var date = new DateTimeOffset(new DateTime(2015, 1, 1)); times[i] = calc.GetPrayerTimes(date.AddDays(i), -7); } Assert.Equal(new DateTime(2015, 2, 3), times[33].Date); Assert.Equal(new TimeSpan(6, 8, 0), times[33].Fajr); }
public void TestTimeForNonDst() { PrayerTimesCalculator calc = new PrayerTimesCalculator(47.660918, -122.136371); calc.CalculationMethod = CalculationMethods.ISNA; calc.AsrJurusticMethod = AsrJuristicMethods.Shafii; var times = calc.GetPrayerTimes(new DateTime(2015, 2, 3), -7); Assert.Equal(new DateTime(2015, 2, 3), times.Date); Assert.Equal(new TimeSpan(6, 8, 0), times.Fajr); Assert.Equal(new TimeSpan(7, 37, 0), times.Sunrise); Assert.Equal(new TimeSpan(12, 22, 0), times.Dhuhr); Assert.Equal(new TimeSpan(14, 44, 0), times.Asr); Assert.Equal(new TimeSpan(17, 08, 0), times.Maghrib); Assert.Equal(new TimeSpan(17, 08, 0), times.Sunset); Assert.Equal(new TimeSpan(18, 36, 0), times.Isha); }
public void TestTimeForDstAutoTimeZone() { PrayerTimesCalculator calc = new PrayerTimesCalculator(47.660918, -122.136371); calc.CalculationMethod = CalculationMethods.ISNA; calc.AsrJurusticMethod = AsrJuristicMethods.Shafii; var times = calc.GetPrayerTimes(new DateTime(2015, 8, 3, 0, 0, 0, DateTimeKind.Local)); Assert.Equal(new DateTime(2015, 8, 3, 0, 0, 0, DateTimeKind.Local), times.Date); Assert.Equal(new TimeSpan(4, 1, 0), times.Fajr); Assert.Equal(new TimeSpan(5, 48, 0), times.Sunrise); Assert.Equal(new TimeSpan(13, 15, 0), times.Dhuhr); Assert.Equal(new TimeSpan(17, 18, 0), times.Asr); Assert.Equal(new TimeSpan(20, 40, 0), times.Maghrib); Assert.Equal(new TimeSpan(20, 40, 0), times.Sunset); Assert.Equal(new TimeSpan(22, 28, 0), times.Isha); }
public void TestTimesForYear() { PrayerTimesCalculator calc = new PrayerTimesCalculator(47.660918, -122.136371); calc.CalculationMethod = CalculationMethods.ISNA; calc.AsrJurusticMethod = AsrJuristicMethods.Shafii; var times = new Times[365]; for (int i = 0; i < 365; i++) { var date = new DateTimeOffset(new DateTime(2015, 1, 1)); times[i] = calc.GetPrayerTimes(date.AddDays(i), -7); } Assert.Equal(new DateTime(2015, 2, 3), times[33].Date); Assert.Equal(new TimeSpan(6, 8, 0), times[33].Fajr); }