Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

timeToMinutes: converts a time value to a number of minutes. In the example below, we have converted current time of 19:20 to 1160 minutes.  Also, you will see that we took minutes and divided it by 60 to get the current hour of the day. That result is 19.33 hours, or 7:20pm (.33 hours is approximately 20 minutes).

Usage Examples

...

Parking Lot Lights

In the example below, we are using the time block to extract just current time from the now block. Then we are using time subtract blocks to determine if the current time is either 15 minutes before sunset or 15 minutes after sunrise.  If either of these conditions are true, then we set the Parking Lot Lights to on. In our example below, current time is 20:17 and sunset time is 20:29. Because the difference is less than 15 minutes, the lights are set on.
Image Added

Another thing we could do with this application is to set the Sunrise, Sunset, and Current Time as Project variables (or global variables), so we wouldn't have to use the weather blocks in every program. We could also package up this lighting application as a Macro in order to use it elsewhere in this project, as well as export it for use in other projects.