
    9jg#                        d Z ddlZddlZddlmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZmZmZ 	 ddlZg dZd	Zd
Zeej                  ej                  f   Zeeeeef   f   ZeZeZeZd"deej6                     dej                  fdZd"deej6                     dej:                  fdZ	 d"deeeef   dee   defdZ dedejB                  fdZ"dejB                  defdZ#dejB                  defdZ$dedefdZ% G d de      Z& G d de      Z'e G d d             Z(e G d d             Z)e G d  d!             Z*y# e$ r
 ddlmZ Y w xY w)#a  Calculations for the position of the sun and moon.

The :mod:`astral` package provides the means to calculate the following times of the sun

* dawn
* sunrise
* noon
* midnight
* sunset
* dusk
* daylight
* night
* twilight
* blue hour
* golden hour
* rahukaalam
* moon rise, set, azimuth and zenith

plus solar azimuth and elevation at a specific latitude/longitude.
It can also calculate the moon phase for a specific date.

The package also provides a self contained geocoder to turn a small set of
location names into timezone, latitude and longitude. The lookups
can be perfomed using the :func:`~astral.geocoder.lookup` function defined in
:mod:`astral.geocoder`
    N)	dataclassfield)Enum)radianstan)OptionalTupleUnion)zoneinfo)	
DepressionSunDirectionObserverLocationInfoAstralBodyPositionnowtodaydms_to_floatrefraction_at_zenithz3.2z(Simon Kennedy <sffjunkie+code@gmail.com>tzreturnc                     t         j                   j                  t         j                  j                        }| |S |j	                  |       S )z3Returns the current time in the specified time zone)datetimer   timezoneutc
astimezone)r   now_utcs     [/var/www/html/eeg-assistent/abrechnung/venv/lib/python3.12/site-packages/astral/__init__.pyr   r   P   s?    ##H$5$5$9$9:G	zb!!    c                 4    t        |       j                         S )z3Returns the current date in the specified time zone)r   date)r   s    r   r   r   Y   s    r7<<>r   dmslimitc                 4   	 t        |       }|||kD  r|}|S || k  r| }|S # t        t        f$ r}d}t        j                  |t        |       t        j                        }|r|j                  d      xs d}|j                  d      xs d}|j                  d      xs d}|j                  d      xs d}	t        |      }|r|t        |      d	z  z  }|r|t        |      d
z  z  }|	j                         dv r| }nt        d      |Y d}~d}~ww xY w)uR  Converts as string of the form `degrees°minutes'seconds"[N|S|E|W]`,
    or a float encoded as a string, to a float

    N and E return positive values
    S and W return negative values

    Args:
        dms: string to convert
        limit: Limit the value between ± `limit`

    Returns:
        The number of degrees as a float
    uW   (?P<deg>\d{1,3})[°]((?P<min>\d{1,2})[′'])?((?P<sec>\d{1,2})[″\"])?(?P<dir>[NSEW])?)flagsdeg        minsecdirE<     )SWz2Unable to convert degrees/minutes/seconds to floatN)	float
ValueError	TypeErrorrematchstr
IGNORECASEgroupupper)
r!   r"   resexc_dms_re	dms_matchr%   min_r(   dir_s
             r   r   r   ^   s%   "Cj. ;C J E6\&CJ9 	" lHHWc#hbmmD	//%(/CC??5)0SD//%(/CC??5)0SD*CuT{R''uSzD((zz|z)dD%s   # DCDDvaluec                     t        |       }| |z  } | dz  } t        |       }| |z  } | dz  } t        |       }| |z  } t        | dz        }t        j                  ||||      S )z;Convert a floating point number of hours to a datetime.timer+   @B )intr   time)r>   hourminutesecondmicroseconds        r   hours_to_timerG      so     u:D	TME	RKEZF	VOE	RKEZF	VOEego&K==vv{;;r   c                     d}|| j                   z  }|| j                  dz  z  }|| j                  dz  z  }|| j                  dz  z  }|S )z;Convert a datetime.time to a floating point number of hoursr&   r+   r,   r@   )rC   rD   rE   rF   r>   hourss     r   time_to_hoursrK      sW     E	UZZE	U\\BE	U\\D  E	U((ELr   c                 "    t        |       }|dz  S )z=Convert a datetime.time to a floating point number of secondsr,   )rK   rI   s     r   time_to_secondsrM      s     % E4<r   zenithc                     d| z
  }|dk\  ryd}t        t        |            }|dkD  r$d|z  d||z  |z  z  z
  d||z  |z  |z  |z  z  z   }n+|d	kD  r!d
|dz  z   }d||z  z   }d||z  z   }d||z  z   }nd|z  }|dz  }|S )zJCalculate the degrees of refraction of the sun due to the sun's elevation.Z   g     @U@r   r&   g      @gM@gQ?g6w\?gffffffgGz)gn?gY@g1g     @g/$4g      @)r   r   )rN   	elevationrefraction_correctiontestep1step2step3s          r   r   r      s     VID	WY	 B32IR"--BGbL2<MPR<R0SS 	 
V	U**	E))U** &U): : '"1F:  r   c                       e Zd ZdZdZdZdZy)r   z>The depression angle in degrees for the dawn/dusk calculations         N)__name__
__module____qualname____doc__CIVILNAUTICALASTRONOMICAL r   r   r   r      s    HEHLr   r   c                       e Zd ZdZdZdZy)r   z-Direction of the sun either RISING or SETTING   N)r[   r\   r]   r^   RISINGSETTINGrb   r   r   r   r      s    7FGr   r   c                   f    e Zd ZU dZ ee      Zeed<    ee      Z	eed<    ee      Z
eed<   y)r   z1The position of an astral body as seen from earth)default_factoryright_ascensiondeclinationdistanceN)r[   r\   r]   r^   r   r/   rj   Radians__annotations__rk   rl   rb   r   r   r   r      s2    ;$U;OW; 7K7e4Hg4r   r   c                   d     e Zd ZU dZdZeed<   dZeed<   dZe	ed<   de
d	ee
ee	f   f fd
Z xZS )r   u'  Defines the location of an observer on Earth.

    Latitude and longitude can be set either as a float or as a string.
    For strings they must be of the form

        degrees°minutes'seconds"[N|S|E|W] e.g. 51°31'N

    `minutes’` & `seconds”` are optional.

    Elevations are either

    * A float that is the elevation in metres above a location, if the nearest
      obscuring feature is the horizon
    * or a tuple of the elevation in metres and the distance in metres to the
      nearest obscuring feature.

    Args:
        latitude:   Latitude - Northern latitudes should be positive
        longitude:  Longitude - Eastern longitudes should be positive
        elevation:  Elevation and/or distance to nearest obscuring feature
                    in metres above/below the location.
    1*I@latitude~:NK	longituder&   rQ   namer>   c                     |dk(  rt        |d      }nO|dk(  rt        |d      }n=|dk(  r8t        |t              rt        |d         t        |d         f}nt        |      }t        |   ||       y )Nrq        V@rs        f@rQ   r   rd   )r   
isinstancetupler/   super__setattr__selfrt   r>   	__class__s      r   r{   zObserver.__setattr__  so    : -E[  .E[ %'uQx%a/:eD%(r   )r[   r\   r]   r^   rq   Degreesrn   rs   rQ   	Elevationr4   r
   r/   r{   __classcell__r~   s   @r   r   r      sL    .  Hg#Iw#Iy
) 
)E#ui2G,H 
) 
)r   r   c                        e Zd ZU dZdZeed<   dZeed<   dZeed<   dZ	e
ed	<   d
Ze
ed<   dedee
ef   f fdZed        Zed        Zed        Z xZS )r   u  Defines a location on Earth.

    Latitude and longitude can be set either as a float or as a string.
    For strings they must be of the form

        degrees°minutes'seconds"[N|S|E|W] e.g. 51°31'N

    `minutes’` & `seconds”` are optional.

    Args:
        name:       Location name (can be any string)
        region:     Region location is in (can be any string)
        timezone:   The location's time zone (a list of time zone names can be
                    obtained from `zoneinfo.available_timezones`)
        latitude:   Latitude - Northern latitudes should be positive
        longitude:  Longitude - Eastern longitudes should be positive
    	Greenwichrt   EnglandregionzEurope/Londonr   rp   rq   rr   rs   r>   c                 l    |dk(  rt        |d      }n|dk(  rt        |d      }t        | 	  ||       y )Nrq   rv   rs   rw   )r   rz   r{   r|   s      r   r{   zLocationInfo.__setattr__)  s:    : -E[  .ED%(r   c                 D    t        | j                  | j                  d      S )z#Return an Observer at this locationr&   )r   rq   rs   r}   s    r   observerzLocationInfo.observer0  s     t~~s;;r   c                 @    t        j                  | j                        S )z,Return a zoneinfo.ZoneInfo for this location)r   ZoneInfor   r   s    r   tzinfozLocationInfo.tzinfo5  s       //r   c                 B    | j                   j                  dd      d   S )z!Return the group a timezone is in/rd   )maxsplitr   )r   splitr   s    r   timezone_groupzLocationInfo.timezone_group:  s#     }}""3"3A66r   )r[   r\   r]   r^   rt   r4   rn   r   r   rq   r   rs   r
   r{   propertyr   r   r   r   r   s   @r   r   r     s    $ D#FC#Hc#Hg#Iw#) )E'3,,? ) < < 0 0 7 7r   r   )N)+r^   r   r2   dataclassesr   r   enumr   mathr   r   typingr   r	   r
   r   ImportError	backports__all____version__
__author__
TimePeriodr/   r   r   rm   Minutesr   r   r    r   r4   r   rB   rG   rK   rM   r   r   r   r   r   r   rb   r   r   <module>r      s  "6  	 (   ) )#

 7
 8$$h&7&778
%ue|,,-	


"HX__% "1B1B "hx' 8==  AE/	sE9$	%/.6uo/
/d< <8== < 	 	5 	8== U ! !5 !4 4  5 5 5 &) &) &)R -7 -7 -7w  #""#s   D< <E
E