solar v0.1.0 Solar.Events

The Solar.Events module provides the calculations for sunrise and sunset times. This is likely to be refactored as other events are added.

Summary

Functions

Calculates the hours of daylight returning as a time with hours, minutes and seconds

The event function takes a minimum of two parameters, the event of interest which can be either :rise or :set and the latitude and longitude. Additionally a list of options can be provided as follows

Types

latitude()
latitude() :: number
longitude()
longitude() :: number
message()
message() :: String.t

Functions

daylight(rise, set)

Calculates the hours of daylight returning as a time with hours, minutes and seconds.

event(type, location, opts \\ [])

The event function takes a minimum of two parameters, the event of interest which can be either :rise or :set and the latitude and longitude. Additionally a list of options can be provided as follows:

  • date: allows a value of either :today or an Elixir date. The default if this option is not provided is the current day.
  • zenith: can be set to define the sunrise or sunset. See the Zeniths module for a set of standard zeniths that are used. The default if a zenith is not provided is :official most commonly used for sunrise and sunset.
  • timezone: can be provided and should be a standard timezone identifier such as “America/Chicago”. If the option is not provided, the timezone is taken from the system and used.

Examples

The following, with out any options and run on December 25:

iex> Solar.event (:rise, {39.1371, -88.65})
{:ok,~T[07:12:26]}

iex> Solar.event (:set, {39.1371, -88.65})
{:ok,~T[16:38:01]}

The coordinates are for Lake Sara, IL where sunrise on this day will be at 7:12:26AM and sunset will be at 4:38:01PM.