We have moved at community.getvera.com

Author Topic: new sun time calculations in Lua  (Read 2940 times)

guest4690

  • Guest
new sun time calculations in Lua
« on: June 30, 2010, 11:09:58 am »
Hi

I've finally assimilated and cleaned up the code posted by Ap15e to calculate the time when the sun reaches a given position:
http://code.mios.com/svn_public/mios_genericutils/suntime.lua

the easiest way to use it:
Code: [Select]
require "suntime"

local sunset = suntime.fallto (-50/60)
or, to use it to set a callback at that time:
Code: [Select]
luup.call_timer('callatsunset', 4, os.date('%Y-%m-%d %H:%M:%S', suntime.fallto (-50/60)), nil, cbdata)

please check it out... i might have mixed some things, especially the localtime handling.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: new sun time calculations in Lua
« Reply #1 on: June 30, 2010, 05:50:23 pm »
Nice assimilation!

Just a small typo:

Quote
local t = to (altitude, time, place)

- and, please give credit where credit is due:

--- Source:
---    Almanac for Computers, 1990
---    published by Nautical Almanac Office
---    United States Naval Observatory
---    Washington, DC 20392

guest4690

  • Guest
Re: new sun time calculations in Lua
« Reply #2 on: June 30, 2010, 05:57:57 pm »
thks, fixed

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: new sun time calculations in Lua
« Reply #3 on: June 30, 2010, 06:03:51 pm »
For more demanding tasks I recommend IAU's SOFA library: http://www.iausofa.org/  :)
« Last Edit: June 30, 2010, 06:26:45 pm by Ap15e »