Skip to content

default timezone to observer timezone #101

@petaflot

Description

@petaflot

simple example:

from astral import LocationInfo

TZ= 'GMT+2'

where = LocationInfo('here', 'Switzerland', TZ, 47.2, 7.0)

print((
    f"Information for {where.name}/{where.region}\n"
    f"Timezone: {where.timezone}\n"
    f"Latitude: {where.latitude:.02f}; Longitude: {where.longitude:.02f}\n"
))

from datetime import datetime
from astral.sun import sun
s = sun(where.observer, date=datetime.now())
print((
    f'Sunrise:    {s["sunrise"]}\n'
))

result:

Information for here/Switzerland
Timezone: GMT+2
Latitude: 47.20; Longitude: 7.00

Sunrise:    2025-04-20 11:30:48+00:00

What I expect

timezone used to display times should match timezone specified for observer

Information for here/Switzerland
Timezone: GMT+2
Latitude: 47.20; Longitude: 7.00

Sunrise:    2025-04-20 13:30:48+02:00

Note

actual times are bogus

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions