You Are Here:

Community: Wiki

This page was last modified on 20 August 2009, at 15:28.

Calculating Azan Time by S60 Widgets

From Forum Nokia Wiki


Contents

Introduction

Muslims are supposed to perform five prayers every day. Each prayer is given a certain prescribed time in which it must be performed. To determine the exact time period for each prayer, we need to determine several points of time per a day. To determine the prayer times we must know the location (to know sunrise and sunset of the day). This article describes how we can use location information by using Location service API to calculate the prayer times. Following code shows how we can calculate Longitude and Latitude by using Location API.

Pre condition

This will only work on S60 5th Edition devices, like Nokia 5800. This will not work on a Nokia N95, for example, which is a S60 3rd Edition FP1 device.

Location Calculation

Locationcalculate returns the longitude and latitude of the device location.

function Locationcalculate()
{
 
var serviceObj = null;
 
// Initializes the widget
 
// Obtain the Location service object
try {
serviceObj = device.getServiceObject("Service.Location", "ILocation");
} catch (ex) {
alert("Service object cannot be found.");
return;
}
 
// We are interested in basic location information (longitude, latitude
// and altitude) only, so let's define the criteria respectively
var criteria = new Object();
criteria.LocationInformationClass = "BasicLocationInformation";
 
// Obtain the location information (synchronous)
var result = serviceObj.ILocation.GetLocation(criteria);
var latitude = result.ReturnValue.Latitude;
var longitude = result.ReturnValue.Longitude;
return [latitude, longitude];
}

Prayer Time Calculation

This link provides the actual calculation formula as java script that has been reused here. Obtained latitude and longitude are passed to the calculation module in the following way.

var date = new Date(); // today
 
// Send latitude, longitude and time zone. Time zone is based on 15 dg apart with longitude
var zone = Math.ceil(result[1]/15.0)+1;
AzanTimes = prayTime.getPrayerTimes(date, result[0], result[1], zone);

Example Applications

Complete Azan application can be downloaded for free from [1]. This version is unsigned, it needs to be Symbian signed.
This example has been tested with Nokia 5800. Implementation can be found from following link: File:AzanWidget.zip

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia