Don't know that there is any interest in this sort of thing. But math can be fun and needing a distraction, I hack this script together last evening. It is a combination of somebody else's algorithm laying around on the workstation begging to be converted to WIL and a few UDF's stolen from other projects. The times are off by a couple of minutes but I am too lazy to figure out why. Per as usual typos and bugs are provided at no extra charge.

;;; SunriseSet.wbt

gosub UDPS ; Define functions

; Convert longitude to hour.

longitude = -122.69 ; Longitude is positive for East and negative for West.

latitude = 47.66

zenith = 90.8 ; Rough guess. Should be caclulated.

Date = TimeYmdHms()

SunRise = SunRiseSetTime( longitude, latitude, zenith, Date, @True)

SunSet = SunRiseSetTime( longitude, latitude, zenith, Date, @False)

Message("Today's Sunrise and SunSet", 'Rise ':SunRise:@lf:'Set ': SunSet)

exit

:UDPS ; User-defined procedure definitions.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; SunRiseSetTime

;; Calculates sunrise or sunset for the

;; given location on the given date.

;;

;; Intput - longitude: longitude of the location to calculate(Positive

;; for East and negative for West)

;; latitude: latitude of location to calculate

;; zenith: sun's zenith at location

;; date: date to calculate for

;; bRise: @True to return sunrise @False for sunset

;;

;; Returns - hour:minute:second am/pm of sunrise or set.

;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

#DefineFunction SunRiseSetTime( _longitude, _latitude, _zenith, _Date, _bRise)

Doy=DayOfYear(_Date)

lngHour = _longitude / 15

if _bRise then t = Doy + ((6 - lngHour) / 24)

else t = Doy + ((18 - lngHour) / 24)

; Calculate the Sun's mean anomaly.

m = (0.9856 * t) - 3.289

; Calculate the Sun's true longitude.

l = ((m + (1.916 * sin(m*@Deg2Rad)) + (0.020 * sin(2 * m*@Deg2Rad)) + 282.634))

if l > 360 then l -= 360

else if l < 0 then l += 360

; Calculate the Sun's right ascension.

ra = (atan(0.91764 * tan(l*@Deg2Rad)))* @Rad2Deg

; Right ascension value needs to be in the same quadrant as L

Lquadrant = (floor( l/90)) * 90

RAquadrant = (floor(ra/90)) * 90

ra = ra + (Lquadrant - RAquadrant)

; Right ascension value needs to be converted into hours.

ra = ra / 15

; Calculate the Sun's declination.

sinDec = 0.39782 * sin(l*@Deg2Rad)

cosDec = cos(asin(sinDec))

; Calculate the Sun's local hour angle using the zenith.

csH = (cos(_zenith*@Deg2Rad) - (sinDec * sin(_latitude*@Deg2Rad)) / (cosDec * cos(_latitude*@Deg2Rad)))

if (csH > 1)

Message('SunRiseSetTime', 'the sun never rises at this location (on the specified date)')

return 0

elseif (csH < -1)

Message('SunRiseSetTime', 'the sun never sets at this location (on the specified date)')

return 0

endif

; Finish calculating H and convert into hours.

if _bRise then H = 360 - (acos(csH )/@Deg2Rad)

else H = acos(csH)/@Deg2Rad

H /= 15

; Calculate the local mean time of rising/setting.

T = H + ra - (0.06571 * t) - 6.622

; Adjust back to UTC

UT = T - lngHour ;

;NOTE: UT potentially needs to be adjusted into the range [0,24) by adding/subtracting 24.

if UT < 0 then UT += 24

else if UT > 24 then UT -= 24

LT = TimeFloatToHms(UT, _Date)

LT = TimeAdjustCurrentZone(LT)

LT = TimeFormat(LT, 'hh:mm:ss t')

return LT ; Finally.

#EndFunction

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Day of the year

;; Input - Today's date in YMDHMS

;;

;; Return - the day of the year

;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

#DefineFunction DayOfYear(_ToDate)

ThisYear=ItemExtract(1,_ToDate,":")

JanFirst="%thisyear%:01:01:00:00:00"

JanFirstJulian=TimeJulianDay(JanFirst)

ToJulian=TimeJulianDay(_ToDate)

doy=ToJulian-JanFirstJulian+1

return (doy)

#EndFunction

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; TimeAdjustCurrentZone

;; Input - WIL YMDHMS UTC time.

;;

;; Returns - WIL YMDHMS time converted to local

;; time.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

#DefineFunction TimeAdjustCurrentZone(_strUtcTime)

nActiveBias = RegQueryDword(@regmachine,"SYSTEM\CurrentControlSet\Control\TimeZoneInformation[ActiveTimeBias]", 0)

If nActiveBias >= 0

Return TimeSubtract(_strUtcTime,"0000:00:00:00:":nActiveBias:":00")

Else

Return TimeAdd(_strUtcTime,"0000:00:00:00:":Abs(nActiveBias):":00")

#EndFunction

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Floating point time of day to date.

;; Input - Floating point time of day

;; Date of day

;;

;; Return - Current YMDHMS date using input

;; time of day.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

#DefineFunction TimeFloatToHms(_FloatHour, _now)

Hour = floor(_FloatHour)

Rem = _FloatHour - Hour

Minu = floor(Rem*60)

Rem = (Rem*60) - Minu

Sec = floor(Rem * 60)

Result = ItemReplace(Int(Hour), 4, _now, ':')

Result = ItemReplace(Int(Minu) , 5, Result, ':')

Result = ItemReplace(Int(Sec), 6, Result, ':')

return Result

#EndFunction

return ; UDP gosub return.