[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to compute Sunrise / Sunset ?

Joe Joe

9/19/2007 1:24:00 PM

I need to compute sunrise/set times in ruby for a given long lat. Does
anyone know any way to do this? Are there any modules or helper classes
out there??

thanks!
--
Posted via http://www.ruby-....

11 Answers

Marcin Raczkowski

9/19/2007 1:31:00 PM

0

Joe Joe wrote:
> I need to compute sunrise/set times in ruby for a given long lat. Does
> anyone know any way to do this? Are there any modules or helper classes
> out there??
>
> thanks!
sunrise/sunset differ based on location and time, i think there are very
complicated equations for this but since it's so specific i doubt
anyone done this already, you probably should find webservice or page
that does that and use SOAP or mechanize to get it from there

SpringFlowers AutumnMoon

9/19/2007 1:46:00 PM

0

and it changes during the year too...

--
Posted via http://www.ruby-....

tichy

9/19/2007 2:30:00 PM

0

On Sep 19, 3:30 pm, Marcin Raczkowski <mailing...@gmail.com> wrote:
> Joe Joe wrote:

> [...]

> sunrise/sunset differ based on location and time,
> i think there are very complicated equations [...]

Moderately complicated, I would say ;)

http://en.wikipedia.org/wiki/Sunris...

Joe Joe

9/19/2007 2:38:00 PM

0

Szymon 'tichy' wrote:
> On Sep 19, 3:30 pm, Marcin Raczkowski <mailing...@gmail.com> wrote:
>> Joe Joe wrote:
>
>> [...]
>
>> sunrise/sunset differ based on location and time,
>> i think there are very complicated equations [...]
>
> Moderately complicated, I would say ;)
>
> http://en.wikipedia.org/wiki/Sunris...

I found some python code to do it. It's pretty complicated and before I
tackle writing it in ruby, I figured I'd ask to see if anyone else has
tackled it.

http://kortis.to/radix/py...
--
Posted via http://www.ruby-....

Marcin Raczkowski

9/19/2007 2:43:00 PM

0

Szymon 'tichy' wrote:
> On Sep 19, 3:30 pm, Marcin Raczkowski <mailing...@gmail.com> wrote:
>> Joe Joe wrote:
>
>> [...]
>
>> sunrise/sunset differ based on location and time,
>> i think there are very complicated equations [...]
>
> Moderately complicated, I would say ;)
>
> http://en.wikipedia.org/wiki/Sunris...
>
>
>
did you actually read article, to use that "moderately" complicated
equation you have to calculate local noon, calculate declinations,
convert hours to hours angles, also take into consideration such things
as day-saving time, time zones etc.

anway here's page that calculates sunrise and sunset
http://aa.usno.navy.mil/data/docs/RS_O...

Marcin Raczkowski

9/19/2007 2:46:00 PM

0

Joe Petrini wrote:
> Szymon 'tichy' wrote:
>> On Sep 19, 3:30 pm, Marcin Raczkowski <mailing...@gmail.com> wrote:
>>> Joe Joe wrote:
>>> [...]
>>> sunrise/sunset differ based on location and time,
>>> i think there are very complicated equations [...]
>> Moderately complicated, I would say ;)
>>
>> http://en.wikipedia.org/wiki/Sunris...
>
> I found some python code to do it. It's pretty complicated and before I
> tackle writing it in ruby, I figured I'd ask to see if anyone else has
> tackled it.
>
> http://kortis.to/radix/py...

well looks like 3/4 of the code is simple unit exchange, anyway if you
succeed please share ;)

tichy

9/19/2007 2:57:00 PM

0

tichy

9/19/2007 3:23:00 PM

0

I overlooked straight solution...
Emacs editor has a calendar.
I think code in solar.el file is accurate.

http://cvs.savannah.gnu.org/viewvc/emacs/emacs/lisp/calendar/solar.el?v...

Ken Bloom

9/19/2007 3:38:00 PM

0

On Wed, 19 Sep 2007 22:23:47 +0900, Joe Joe wrote:

> I need to compute sunrise/set times in ruby for a given long lat. Does
> anyone know any way to do this? Are there any modules or helper classes
> out there??
>
> thanks!

I have previously posted code for this at
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-t...

--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu...

Joe Joe

9/19/2007 4:00:00 PM

0

Ken Bloom wrote:
> On Wed, 19 Sep 2007 22:23:47 +0900, Joe Joe wrote:
>
>> I need to compute sunrise/set times in ruby for a given long lat. Does
>> anyone know any way to do this? Are there any modules or helper classes
>> out there??
>>
>> thanks!
>
> I have previously posted code for this at
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-t...

I just came across that and had a little trouble getting it working but
realized I was passing a datetime instead of a Date.

For anyone else interested put the code above in a file sunrise.rb:
require 'Sunrise'
include Sunrise
#Create the location
loc = Sunrise::Location.new(39.2,-75.1)
Create the date
d = Date.new(2007,9,19)
sunrisetime = sunrise(d,p)


Thanks for the code, it's a lifesaver!!

--
Posted via http://www.ruby-....