Update README

This commit is contained in:
Nemo 2020-05-22 20:00:20 +05:30
parent 8531377d9c
commit 621f769441
2 changed files with 9 additions and 1 deletions

View File

@ -20,7 +20,14 @@ Crystal library for calculating sunrise and sunset times. Uses the algorithm fro
require "suntime"
# Time is optional, local time is used otherwise
Suntime.new(lat,long, time)
# It returns sunrise/sunset for TODAY, so if you want the next sunset, check accordingly
s = Suntime::Suntime.new(lat,long, time)
# Bangalore
s = Suntime::Suntime.new(12.955800, 77.620979)
s.sunrise
# 2020-05-22 05:52:48.0 +05:30 Local
s.sunset
# 2020-05-22 18:39:43.0 +05:30 Local
```
## Development

View File

@ -8,6 +8,7 @@ describe Suntime do
l = Time::Location.load("America/New_York")
t = Suntime::Suntime.new(lat, lng, Time.local(1990, 6, 25, 0, 0, 0, location: l))
# TODO: These are stupid tests, figure out how to use epsilon for float tests in Crystal
t.day_of_year.should eq(176)
t.approx_time.should eq(176.45638888888888)
t.approx_time(false).should eq(176.95638888888888)