Comments (8)
This is the workaround I am using
def sunset(dt):
sun = Sun(LAT, LON)
ss = sun.get_local_sunset_time(dt)
sr = sun.get_local_sunrise_time(dt)
if ss < sr:
ss = ss + datetime.timedelta(1)
return ss
from suntime.
Just noticed it too. It just smashed an hour of work. >.<
Even when the timezone is set in pandas
(e.g. tz='America/New_York'
), the resulting sunset date is back in utc.
You can force it via:
sun.get_local_sunset_time(dt).replace(tzinfo=pytz.utc).astimezone(pytz.timezone('America/New_York'))
from suntime.
I'll check it thanks for reporting!
from suntime.
Just stumbled across this myself, thanks for the workarounds.
from suntime.
I have a similar issue, but I don't think its related to timezone - when getting sunrise/sunset times 2020 in a single location (long = -83.09, lat = 40.18) the sunset time reverts to a day back on 4/3/2020.
...snip...
Sunrise: 1585466400.0 - Sunset: 1585511640.0 - Daylight hr: 12.57
Sunrise: 1585552680.0 - Sunset: 1585598100.0 - Daylight hr: 12.62
Sunrise: 1585639020.0 - Sunset: 1585684560.0 - Daylight hr: 12.65
Sunrise: 1585725300.0 - Sunset: 1585771020.0 - Daylight hr: 12.7
Sunrise: 1585811640.0 - Sunset: 1585857480.0 - Daylight hr: 12.73
Sunrise: 1585897920.0 - Sunset: 1585943940.0 - Daylight hr: 12.78
Sunrise: 1585984200.0 - Sunset: 1585944000.0 - Daylight hr: -11.17
Sunrise: 1586070540.0 - Sunset: 1586030520.0 - Daylight hr: -11.12
Sunrise: 1586156820.0 - Sunset: 1586116980.0 - Daylight hr: -11.07
...snip...
@jfbauer432's solution worked for me.
from suntime.
I just found this issue too. No fix two years later?
from suntime.
Solved in #19
tested using this:
import datetime
import pytz
sun = Sun(38.8895, -77.0353)
tz = pytz.timezone('America/New_York')
day = datetime.datetime(2020, 4, 29, 7, 35, 24, 335561)
day
print(sun.get_sunrise_time(day))
print(sun.get_sunset_time(day))
print("")
print(sun.get_sunrise_time(day, tz=tz))
print(sun.get_sunset_time(day, tz=tz))
sun = Sun(39.8895, -77.0353)
tz = pytz.timezone('America/New_York')
day = datetime.datetime(2020, 4, 29, 7, 35, 24, 335561)
day
print(sun.get_sunrise_time(day))
print(sun.get_sunset_time(day))
print("")
print(sun.get_sunrise_time(day, tz=tz))
print(sun.get_sunset_time(day, tz=tz))
But, it merely change the date. Can you help me confirm my solution @jfbauer432?
from suntime.
Yeah, but the pull request hasn't been merged yet so still no fix. Testing if sunset is before sunrise is still the only valid solution, beside modifying the source on my end,
from suntime.
Related Issues (16)
- ValueError on corner case
- Sunrise after sunset for NZ coordinates HOT 5
- Did suntime change? HOT 2
- North and south latitude problems HOT 4
- Big issue of suntime HOT 3
- Inconsistent sunrise times between neighbouring zones HOT 5
- cannot import name 'Sun' from partially initialized module 'suntime' (most likely due to a circular import) HOT 6
- Sunrise local time is out by 1 hour a day before daylight savings starts. Sunset is correct.
- Bug in day wrap for sunset times HOT 2
- No seconds calculations? HOT 1
- Buglet in example HOT 1
- Update datetime with current date HOT 1
- Publish on PiPy HOT 1
- Another ValueError on corner case HOT 1
- Tests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from suntime.