
    R1iD                         d Z d ZddZd Zy)zGeneral-purpose routines.

It seemed a shame for the ``api`` module to have to import large legacy
modules to offer simple date handling, so this small module holds the
routines instead.

c                     d| z  d| |dz   dz  z   z  dz  dz  z
  d|z  dz  dz  z   |z   d	z   }||d
z  z   |dz  z   dz  }||f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.

    This function is a simple translation to Python of the C++ routine
    ``jday()`` in Vallado's ``SGP4.cpp``.

    g     v@   	   g      (@g      ?g      ?i  g      "@g   B:A      N@g      @     @ )yearmondayhrminutesecjdfrs           R/home/cursorai/projects/iching/venv/lib/python3.12/site-packages/sgp4/functions.pyjdayr      s    2 $,qT)*+d2c9:	Ci#o 

 	B
 
V
+w	6Br6M    c                 T   |dz  }|rt        ||      }t        |d      \  }}|rt        ||      }t        |      }t        |d      \  }}t        |d      \  }}| dz  dk(  xs | dz  dk(  xr | dz  dk7  }t        ||      \  }}	|d	k(  rd
}|	dz  }	||	t        |      t        |      |fS )a  Convert a float point number of days into the year into date and time.

    Given the integer year plus the "day of the year" where 1.0 means
    the beginning of January 1, 2.0 means the beginning of January 2,
    and so forth, return the Gregorian calendar month, day, hour,
    minute, and floating point seconds.

    >>> days2mdhms(2000, 1.0)   # January 1
    (1, 1, 0, 0, 0.0)
    >>> days2mdhms(2000, 32.0)  # February 1
    (2, 1, 0, 0, 0.0)
    >>> days2mdhms(2000, 366.0)  # December 31, since 2000 was a leap year
    (12, 31, 0, 0, 0.0)

    The floating point seconds are rounded to an even number of
    microseconds if ``round_to_microsecond`` is true.

    r   r   <      i         d            )rounddivmodint_day_of_year_to_month_day)
r   daysround_to_microsecondsecondr   hourday_of_yearis_leapmonthr
   s
             r   
days2mdhmsr'   )   s    & G^Fv34FD)NFFv34[F&"%LD&tR(KSjAoD$(a-"CD3J!OG*;@JE3{r	#s4y#f+v55r   c                     d|z
  | d|z   k\  z  }| dk\  }t        d| dz
  d|z  z   |z   z  d      \  }}|d|z
  z  }|dz  }|dz  }||fS )z:Core logic for turning days into months, for easy testing.   r            =   )r   )r$   r%   february_bumpaugustr&   r
   s         r   r   r   P   st    [[BL%@AMCF[1_rF{:]JKRPJE3	QZEAIC1HC#:r   N)   )__doc__r   r'   r   r   r   r   <module>r2      s   B%6Nr   