
    Qfg#                        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n# e$ r	 ddlmZ Y nw xY w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j                 dej        fdZd"deej                 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j!        fdZ"dej!        defdZ#dej!        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*dS )#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                             t           j        j                  }| |S |                    |           S )z3Returns the current time in the specified time zone)datetimer   timezoneutc
astimezone)r   now_utcs     N/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/astral/__init__.pyr   r   P   s<    ##H$5$9::G	zb!!!    c                 D    t          |                                           S )z3Returns the current date in the specified time zone)r   date)r   s    r   r   r   Y   s    r77<<>>r   dmslimitc                 z   	 t          |           }n# t          t          f$ r}d}t          j        |t          |           t          j                  }|r|                    d          pd}|                    d          pd}|                    d          pd}|                    d          pd}	t          |          }|r|t          |          d	z  z  }|r|t          |          d
z  z  }|	                                dv r| }nt          d          |Y d}~nd}~ww xY w|||k    r|}n
|| k     r| }|S )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   ^   sg   "Cjj	"   lHWc#hhbmDDD	 	//%((/CC??5))0SD//%((/CC??5))0SD**C (uT{{R'' )uSzzD((zz||z))dD %, ;;CCE6\\&CJs    D#C5D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      sy     u::D	TME	RKEZZF	VOE	RKEZZF	VOEego&&K=vv{;;;r   c                 l    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      sN     E	UZ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dS d}t          t          |                    }|dk    r$d|z  d||z  |z  z  z
  d||z  |z  |z  |z  z  z   }n,|d	k    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q	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dS )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HEHLLLr   r   c                       e Zd ZdZdZdZdS )r   z-Direction of the sun either RISING or SETTING   N)r[   r\   r]   r^   RISINGSETTINGrb   r   r   r   r      s        77FGGGr   r   c                   z    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<   dS )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      so         ;;$uU;;;OW;;; 5777K777e444Hg44444r   r   c                   j     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                 R   |dk    rt          |d          }nl|dk    rt          |d          }nU|dk    rOt          |t                    r+t          |d                   t          |d                   f}nt          |          }t	                                          ||           d S )Nrq        V@rs        f@rQ   r   rd   )r   
isinstancetupler/   super__setattr__selfrt   r>   	__class__s      r   r{   zObserver.__setattr__  s    : --EE[   ..EE[  %'' %uQx%a//:eD%(((((r   )r[   r\   r]   r^   rq   Degreesrn   rs   rQ   	Elevationr4   r
   r/   r{   __classcell__r~   s   @r   r   r      s          .  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                     |dk    rt          |d          }n|dk    rt          |d          }t                                          ||           d S )Nrq   rv   rs   rw   )r   rz   r{   r|   s      r   r{   zLocationInfo.__setattr__)  sY    : --EE[   ..ED%(((((r   c                 8    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                 4    t          j        | j                  S )z,Return a zoneinfo.ZoneInfo for this location)r   ZoneInfor   r   s    r   tzinfozLocationInfo.tzinfo5  s      ///r   c                 F    | 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"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,,? ) ) ) ) ) ) < < X< 0 0 X0 7 7 X7 7 7 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      sT  " 6  				 ( ( ( ( ( ( ( (               ) ) ) ) ) ) ) ) ) )#OOOO # # #""""""""#
 
 
 7
 8$h&778
%ue|,,-	


" "HX_% "1B " " " " hx' 8=     AE/ /	sE9$	%/.6uo/
/ / / /d< <8= < < < < 	 	5 	 	 	 	8= U    ! !5 ! ! ! !4           4    5 5 5 5 5 5 5 5 &) &) &) &) &) &) &) &)R -7 -7 -7 -7 -7 -7 -7 -7 -7 -7s   1 ??