Git Product home page Git Product logo

Comments (8)

jfbauer432 avatar jfbauer432 commented on August 14, 2024 9

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.

suuuehgi avatar suuuehgi commented on August 14, 2024 1

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.

SatAgro avatar SatAgro commented on August 14, 2024

I'll check it thanks for reporting!

from suntime.

jbeale1 avatar jbeale1 commented on August 14, 2024

Just stumbled across this myself, thanks for the workarounds.

from suntime.

thinktwisted avatar thinktwisted commented on August 14, 2024

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.

dhowland avatar dhowland commented on August 14, 2024

I just found this issue too. No fix two years later?

from suntime.

yasirroni avatar yasirroni commented on August 14, 2024

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.

SylvainGa avatar SylvainGa commented on August 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.