##### Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

# Calculating Azan Time by S60 Widgets

Code ExampleArticle
Created: mahbub_s60 (30 Jun 2009)
Last edited: hamishwillee (19 Jul 2012)

## 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

This example has been tested with Nokia 5800. Implementation can be found from following link: