Any Muslims around?

Just wondering if any Muslims have gotten around to making a Ruby script
that like plays a sound or something when it’s time for prayer.

Thanks,
Kyrre Nygård

Just wondering if any Muslims have gotten around to making a
Ruby script
that like plays a sound or something when it’s time for prayer.

I guess time for prayer is at certain times per day? You could
get the current time with Time.now, then sleep the appropriate
time to the next prayer, and then wake up and to whatever you
would like to do.

Ronald

On 8/14/07, Ronald F. [email protected] wrote:

Just wondering if any Muslims have gotten around to making a
Ruby script
that like plays a sound or something when it’s time for prayer.

I guess time for prayer is at certain times per day? You could
get the current time with Time.now, then sleep the appropriate
time to the next prayer, and then wake up and to whatever you
would like to do.

Hi,

you could also have a look at :

http://openwferu.rubyforge.org/scheduler.html

to install it :

sudo gem install openwferu-scheduler

then write a program that looks like :

—8<—

require ‘rubygems’
require ‘openwfe/util/scheduler’

include OpenWFE

scheduler = Scheduler.new
scheduler.start

scheduler.schedule(“0 6 * * *”) do
puts “time for the morning prayer”
end
scheduler.schedule(“0 12 * * *”) do
puts “time for the noon prayer”
end

or

scheduler.schedule(“0 6,8,12,16,18 * * *”) do
puts “bismillah…”
end
—>8—

The scheduler follows the “cron” convention
(man 5 crontab - Google Search)

Maybe you’re better off with a ruby program triggered by the cron in
your system (if it’s a Unix / MacOSX one).

Best regards,

On Tue, 14 Aug 2007 20:50:02 +0900, Kyrre Nygård wrote:

Just wondering if any Muslims have gotten around to making a Ruby script
that like plays a sound or something when it’s time for prayer.

Thanks,
Kyrre Nygård

Would this help? I use it as part of a suite of scripts for computing
times that Orthodox Jews use to compute times for prayer. The algorithm
comes from the US Naval Observatory’s Almanac for Computers.

–Ken

require ‘date’
require ‘mathn’

#methods stolen from ruby-doc.org
class Date
def to_datetime() DateTime.new0(self.class.jd_to_ajd(jd, 0, 0), @of,
@sg) end
def to_date() self end
def to_time() Time.local(year, mon, mday) end
end
class DateTime
def to_date() Date.new0(self.class.jd_to_ajd(jd, 0, 0), 0, @sg) end
def to_datetime() self end
def to_time
d = new_offset(0)
d.instance_eval do
Time.utc(year, mon, mday, hour, min, sec,
(sec_fraction * 86400000000).to_i)
end.
getlocal
end
end

#end stolen

def dms(degrees,minutes,seconds)
degrees+minutes/60+seconds/60/60
end

module Sunrise
include Math
class Location
attr_accessor :latitude, :longitude, :offset
def initialize(latitude,longitude)
@latitude,@longitude=latitude,longitude
end
end

def toRad(degrees)
degrees*PI/180
end

def toDeg(radians)
radians*180/PI
end

def sun_rise_set(which,date,location,zenith)
#step 1: first calculate the day of the year
n=date.yday

  #step 2: convert the longitude to hour value and calculate an

approximate time
lngHour=location.longitude/15
t=n+ ((6-lngHour)/24) if which==:sunrise
t=n+ ((18-lngHour)/24) if which==:sunset

  #step 3: calculate the sun's mean anomaly
  m=(0.9856 * t) - 3.289

  #step 4: calculate the sun's true longitude
  l=  (m+(1.1916 * sin(toRad(m))) + (0.020 * sin(toRad(2*m))) +

282.634) % 360

  #step 5a: calculate the sun's right ascension
  ra = toDeg(atan(0.91764 * tan(toRad(l)))) % 360
  ###step 5b: right ascension value needs to be in the same quadrant

as L
lquadrant = (l/90).floor90
raquadrant = (ra/90).floor
90
ra=ra+(lquadrant-raquadrant)

  #step 5c: right ascension value needs to be converted into hours
  ra/=15

  #step 6: calculate the sun's declination
  sinDec = 0.39782 * sin(toRad(l))
  cosDec = cos(asin(sinDec))
  #step 7a: calculate the sun's local hour angle
  cosH = (cos(toRad(zenith)) - (sinDec * sin(toRad

(location.latitude)))) / (cosDec * cos(toRad(location.latitude)))

  return nil if (not (-1..1).include? cosH)

  #step 7b: finish calculating H and convert into hours
  h = (360 - toDeg(acos(cosH)))/15 if which==:sunrise
  h = (toDeg(acos(cosH)))/15       if which==:sunset
  #step 8: calculate local mean time
  t = h + ra - (0.06571 * t) - 6.622
  t %=24
  #step 9: convert to UTC
  return date.to_datetime+(t - lngHour)/24

end

private :sun_rise_set

def sunrise(date,location,zenith=90.8333)
sun_rise_set :sunrise,date,location,zenith
end
def sunset(date,location,zenith=90.8333)
sun_rise_set :sunset,date,location,zenith
end
end

John M. wrote:

sudo gem install openwferu-scheduler

or

your system (if it’s a Unix / MacOSX one).

Best regards,

Some awesome suggestions here, but I think it’s a bit more complex
considering how times vary from location to location. I guess I’ll have
to try to make sense out of
http://www.arabeyes.org/project.php?proj=ITL. As I said though, I’ll
report back to base once I got something.

Thanks again guys!

All the best,
Kyrre

Some awesome suggestions here, but I think it’s a bit more complex
considering how times vary from location to location.

But you have the timezone for each location, right? If you use the
DateTime
class for calculating times, you can convert between time zones using
the
new_offset method, if you know the offset of the respective time zone to
UTC.

If you only know the name of the time zone, there is a hack on how
to do it using the Time class, described in the “Ruby Cookbook” (which I

would recommend buying anyway). This hack works if your operating system

honours the TZ environment variable. You switch temporarily to this zone

(by changing TZ), get the local time there, and switch back to your own
zone. You then have the time diff to your zone, and you can always get
the time UTC time by calling Time#gmtime.

Ronald

Thanks a lot Ken, and the same to you guys, Ronald and John.

I’ll report back to base once I got something.

All the best,
Kyrre Nygård

On Thu, 16 Aug 2007 17:07:43 +0900, Ronald F. wrote:

would recommend buying anyway). This hack works if your operating system
honours the TZ environment variable. You switch temporarily to this zone
(by changing TZ), get the local time there, and switch back to your own
zone. You then have the time diff to your zone, and you can always get
the time UTC time by calling Time#gmtime.

Ronald

I prefer the tzfile gem for dealing with timezones.

–Ken