Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

The module SunTimesMBS

module SunTimesMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
module Math MBS Util Plugin 12.4 Yes Yes Yes Yes No
Function: A helper module to calculate sunset/sunrise times.
// may be an hour off due to daylight saving time

dim d as new date

dim jd as Double = SunTimesMBS.CalcJulianDate(d.day, d.Month, d.Year)

// Koblenz, Germany
const latitude = 50.356667
const longitude = 7.593889

// Miami, FL
'const latitude = 25.787778
'const longitude = -80.224167

dim sr as Double = SunTimesMBS.CalcSunriseUTC(jd, latitude, longitude)
dim ss as Double = SunTimesMBS.CalcSunsetUTC (jd, latitude, longitude)

d.gmtoffset = 0
d.hour = 0
d.minute = 0
d.second = 0

dim base as Double = d.totalseconds
d.totalseconds = sr*60 + base

MsgBox "Sunrise: "+d.longdate+" "+d.longtime

d.totalseconds = ss*60 + base

MsgBox "Sunset: "+d.longdate+" "+d.longtime
Notes: The example code above works well, but seems not to take into account the daylight saving time.

Feedback, Comments & Corrections

  • method CalcJulianDate(day as Integer, month as Integer, year as Integer) as Double
  • method CalcSunriseUTC(JD as Double, latitude as Double, longitude as Double) as Double
  • method CalcSunsetUTC(JD as Double, latitude as Double, longitude as Double) as Double

Blog Entries

The items on this page are in the following plugins: MBS Util Plugin.

MBS FileMaker Plugins