=====Suntimes===== On starting up, and every day at midnight, XTension will automatically calculate the sunrise and sunset times for your location. There are two verbs which allow you to offset both the sunrise and the sunset times by +/- 90 minutes.\\ See [[:dictionary:xtension:adjustsunriseby|Adjust Sunrise By]] and [[:dictionary:xtension:adjustsunsetby|Adjust Sunset By]] If you have properly set your latitude and longitude for your location using the Time and Date preference panel and your Mac's clock is correct then XTension will do a reasonable job of calculating the expected times of sunrise and sunset. The XTension preferences window also has a Suntimes setup dialog where you can enter a more accurate location or enter offsets: {{ :xtension_manual:preferences_suntimes.png |Suntime Preferences}} Every day at the calculated sunrise time XTension will execute a global script named [[:xtension_manual:specialscripts#sunrisesunset|sunrise]] if you have created one. Likewise at the expected sunset time a script named [[:xtension_manual:specialscripts#sunrisesunset|sunset]] is executed. If there are things that you always want to do at sunrise and/or sunset then you must create these scripts and include the instructions you want. =====Suntimes and whether it is 'daylight'===== Xtension maintains a set of internal variables which hold today's sunrise and sunset times. These variables represent the calculated time of the current day when sunrise and sunset will occur at the latitude/longitude that you have entered in your preferences. In addition, XTension maintains a variable named [[:dictionary:xtension:daylight|daylight]] which can be used in conditional scripts. You cannot set or modify **daylight** directly, this is done automatically by XTension but is based on your preferences setting and offsets as already described. ===Examples:=== if daylight is false then turn on "Front Door Light" end if write log "Sunrise occurs today at " & time string of (sunrise) write log "Sunset will be at " & time string of (sunset) =====Calculating suntimes for a given date===== There are 2 verbs for calculating the sunrise or sunset times for any given date. [[:dictionary:xtension:sunrisefor|sunrise for]] and [[:dictionary:xtension:sunsetfor|sunset for]]. ===Examples:=== set theDate to date "12/25/2012" write log "Sunrise for Christmas will be at: " & sunrise for theDate