# Wiki

##### Actions

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

# Calculating Azan Time by S60 Widgets

Jump to: navigation, search
Article Metadata

Code Example
Article
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

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:

This page was last modified on 19 July 2012, at 08:16.
121 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.