
    R1i                     x    d Z ddlZddlZddlmZmZ  G d dej                        Z e       Z	d Z
d Zdad
d	Zy)zVarious conveniences.

Higher-level libraries like Skyfield that use this one usually have
their own date and time handling.  But for folks using this library by
itself, native Python datetime handling could be convenient.

    N   )
days2mdhmsjdayc                   L    e Zd ZdZ ej
                  d      Zd Zd Zd Z	d Z
y)_UTCUTCr   c                      yNr    )selfs    U/home/cursorai/projects/iching/venv/lib/python3.12/site-packages/sgp4/conveniences.py__repr__z_UTC.__repr__           c                     | j                   S Nzeror   datetimes     r   dstz_UTC.dst       yyr   c                      yr
   r   r   s     r   tznamez_UTC.tzname   r   r   c                     | j                   S r   r   r   s     r   	utcoffsetz_UTC.utcoffset   r   r   N)__name__
__module____qualname____doc__dt	timedeltar   r   r   r   r   r   r   r   r   r      s(    	2<<?Dr   r   c                     | j                  t              }|j                  }|j                  }|j                  }|j
                  }|j                  }|j                  |j                  dz  z   }t        ||||||      S )a  Return two floats that, when added, produce the specified Julian date.

    The first float returned gives the date, while the second float
    provides an additional offset for the particular hour, minute, and
    second of that date.  Because the second float is much smaller in
    magnitude it can, unlike the first float, be accurate down to very
    small fractions of a second.

    >>> jd, fr = jday(2020, 2, 11, 13, 57, 0)
    >>> jd
    2458890.5
    >>> fr
    0.58125

    Note that the first float, which gives the moment of midnight that
    commences the given calendar date, always carries the fraction
    ``.5`` because Julian dates begin and end at noon.  This made Julian
    dates more convenient for astronomers in Europe, by making the whole
    night belong to a single Julian date.

    The input is a native `datetime` object. Timezone of the input is
    converted internally to UTC.

    gư>)

astimezoner   yearmonthdayhourminutesecondmicrosecondr   )r   ur%   monr'   hrr)   secs           r   jday_datetimer0      sm    2 	C A66D
''C
%%C	
BXXF
((Q]]T)
)Cc3FC00r   c           
      .   | j                   }|d|dk  dz  z   z  }| j                  }t        ||      \  }}}}}|dk(  r|dkD  r|dz  }d}|dz  }t        |d      \  }}t	        |      }t	        |dz        }	t        j                  |||||||	t              S )	z=Return the epoch of the given satellite as a Python datetime.il  9   d         r   g      ?g    .A)epochyr	epochdaysr   divmodintr!   r   r   )
satr%   daysr&   r'   r(   r)   r*   fractionmicros
             r   sat_epoch_datetimer>   =   s    ;;DDD2I$$$D==D'1$'=$E3ff{sRx	r	fc*FH[F3E;;tUCvvucJJr   c              #     K   t         g a t        j                  j                         D ]  }|j	                  d      r'|j                  d      }t         j                  |       ;|j                  d      sM|j                  d      }t         j                  |d          d}||   dk(  st         j                  ||dz             |dz  }||   dk(  r) t         D ]  }|d   j                         r|}d	 d
j                  |       0|}t        | |d      }dj                  ||      }|,t        ||d      }	||	k(  rdnd}
dj                  |dd |
|	      }|  yw)z>Yield lines that list the attributes of one or two satellites.N*z| ``z``r      z, r   
z# -------- {0} --------
z	(not set)z{0} = {1!r}
z==z!=z{0:39} {1} {2!r}
)_ATTRIBUTESsgp4r    
splitlinesendswithstripappend
startswithsplitisupperformatgetattr)r:   sat2linetitlepiecesiitemnamevaluevalue2verdicts              r   dump_satrecrY   N   sU     LL++-D}}S!

3""5)(D)""6!9-Qi4'&&vac{3FA Qi4' . 7??EJ-44U;;DC{3E"))$6D t[9#(F?$+2249gvNJ s   A3E!63E!*(E!BE!r   )r    r   r!   rE   	functionsr   r   tzinfor   r   r0   r>   rD   rY   r   r   r   <module>r\      sF      '
299 
 f!1FK r   