Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get dawn at this location on this day #99

Open
nhoover opened this issue Feb 7, 2025 · 1 comment
Open

Can't get dawn at this location on this day #99

nhoover opened this issue Feb 7, 2025 · 1 comment

Comments

@nhoover
Copy link

nhoover commented Feb 7, 2025

from astral import LocationInfo
from zoneinfo import ZoneInfo
from datetime import datetime

# Here is a problematic location in Mongolia
z = ZoneInfo('Asia/Ulaanbaatar')
p = LocationInfo('x', 'x', 'Asia/Ulaanbaatar', 46.79, 101.95)

year = 2025
month = 2

for day in [4, 5, 6]:
    print(f'{year}-{month}-{day}: Sunrise {sunrise(p.observer, datetime(year,month,day).astimezone(z), tzinfo=z)}')
    try:
        print(f'{year}-{month}-{day}: Dawn    {dawn(p.observer, datetime(year,month,day).astimezone(z), tzinfo=z)}')
    except ValueError:
        print(f'Could not get dawn for {year}-{month}{day}')```

Produces this with Astral 3.2 and Python 3.13.1:

2025-2-4: Sunrise 2025-02-04 08:33:09.401354+08:00
2025-2-4: Dawn    2025-02-04 08:00:23.477507+08:00
2025-2-5: Sunrise 2025-02-05 08:31:48.131147+08:00
Could not get dawn for 2025-25
2025-2-6: Sunrise 2025-02-06 08:30:25.162764+08:00
2025-2-6: Dawn    2025-02-06 07:57:50.427476+08:00

There's nothing special I can see about this position or these days. 

Also check out Feb 25. But all the rest of the days of the year look fine.
@nhoover
Copy link
Author

nhoover commented Feb 8, 2025

Here's another one:

# Here's a problematic place in Norway, just above the Arctic circle
z = ZoneInfo('Europe/Oslo')
p = LocationInfo('x', 'x', 'Europe/Oslo', 67.88, 12.98)
print(f'\n{p}')

year = 2025
month = 5
for day in [21, 22, 23, 24, 25, 26]:
    try:
        print(f'{year}-{month:02}-{day:02}: Sunrise {sunrise(p.observer, datetime(year,month,day).astimezone(z), tzinfo=z)}')
    except ValueError:
        print(f'Could not get Sunrise for {year}-{month:02}-{day:02}')

LocationInfo(name='x', region='x', timezone='Europe/Oslo', latitude=67.88, longitude=12.98)
2025-05-21: Sunrise 2025-05-21 02:21:42.785710+02:00
2025-05-22: Sunrise 2025-05-22 02:14:41.780903+02:00
2025-05-23: Sunrise 2025-05-23 02:07:08.157144+02:00
Could not get Sunrise for 2025-05-24
2025-05-25: Sunrise 2025-05-25 01:49:10.855431+02:00
2025-05-26: Sunrise 2025-05-26 01:37:18.380089+02:00

The value for sunrise for 05-24 should be something between the values for the surrounding days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant