ó
å§dRc           @   s!   d  d l  Td d d „  ƒ  YZ d S(   iÿÿÿÿ(   t   *t   eonc           B   s"  e  Z d  Z e d ƒ e e ƒ g Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d d d „ Z  d „  Z! RS(   s®  
	#+
	# NAME:
	#	class eon
	# PURPOSE:
	#	Defines a class for storing times
	# PROCEDURE:
	#	The main instance attributes are
	#
	#	self.ticday   integer, number of days since 2000/01/01 00:00:00 UT
	#	                       i.e. Midnight, Jan 1, 2000 in the Gregorian calendar
	#	self.tictac	  integer, represents the time of day in units of 1/10^self.exponent
	#	self.exponent integer, defines the unit of self.tictac
	#
	#	These three attributes must always be set by the __init__ method.
	#
	#	Other time properties will be calculated only when needed, and are then
	#	also stored as instance attributes for later recall.
	#	This is sometimes already done by the __init__ method, but in general
	#	this task is delegated to the __getattr__ method (which calculates and
	#	stores the property when it is referenced as an attribute).
	#
	#	Currently the following extra attributes are supported:
	#
	#		jd
	#		mjd
	#		njd
	#		posix
	#		jepoch
	#		bepoch
	#
	#	Both Gregorian and Julian calendar are supported. This affects four
	#	time properties:
	#
	#	For Gregorian dates:
	#	    year
	#	    doy
	#	    month
	#	    day
	#
	#	Julian dates are tracked separately:
	#	    julian_year
	#	    julian_doy
	#	    julian_month
	#	    julian_day
	# TODO:
	#	Handle time zones. Currently everything is UTC.
	#	- Input of times with timezone has been implemented (2012-05)
	#	Probably should be handled similar to the Julian calendar.
	#
	#	Documentation
	#-
	c         C   s?   t  d |  j } t |  j | ƒ \ } |  _ |  j | 7_ d S(   s   
		#+
		# NAME:
		#	eon.normalize
		# PURPOSE:
		#	(Internal purposes only)
		#	Is used to normalize eon object (see PROCEDURE).
		# PROCEDURE:
		#	Ensures that self.tictac is positive and is less than one
		#	day. As a result self.ticday will always refer to the
		#	midnight at the beginning of day (in UTC) for the eon object.
		#	Note that neither self.ticday nor self.tictac are forced to
		#	be integer. This is intentional. By the time this routine is
		#	called (by eon.__init__) these quantities should already be
		#	integers.
		#-
		i
   N(   t   g_SECONDS_PER_DAYt   exponentt   divmodt   tictact   ticday(   t   selft   tictacs_per_dayt   day(    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt	   normalize<   s    c         C   sÌ   |  j  d  k r d |  _  n­ t |  j  ƒ r t |  j  ƒ \ } } | d | d d |  j |  _  |  j  d k rÈ |  j |  j  7_ |  j ƒ  qÈ n8 |  j  d k r¾ |  j |  j  8_ |  j ƒ  n  |  j d =d  S(   Ni    i<   i
   t   timezone(   R   t   Nonet	   is_stringt   disassemble_timezoneR   R   R
   t   __dict__(   R   t   tz_hourt	   tz_minute(    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   adjust_for_timezoneU   s     
c         C   s   d |  j  |  j |  j f S(   Ns$   ticday: %s, tictac: %s, exponent: %s(   R   R   R   (   R   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __repr__i   s    c         C   s   d |  j  |  j |  j f S(   Ns$   ticday: %s, tictac: %s, exponent: %s(   R   R   R   (   R   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __str__m   s    c         C   sn   t  | ƒ t j k r t St |  j | j ƒ } |  j | j k om |  j d | |  j | j d | | j k S(   Ni
   (   t   typeR   t   BadTypest   Falset   maxR   R   R   (   R   t   ttR   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __eq__q   s    c         C   sn   t  | ƒ t j k r t St |  j | j ƒ } |  j | j k pm |  j d | |  j | j d | | j k S(   Ni
   (   R   R   R   t   TrueR   R   R   R   (   R   R   R   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __ne__y   s    c         C   sg   t  |  j | j ƒ } |  j | j k  pf |  j | j k of |  j d | |  j | j d | | j k  S(   Ni
   (   R   R   R   R   (   R   R   R   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __lt__   s    c         C   sg   t  |  j | j ƒ } |  j | j k  pf |  j | j k of |  j d | |  j | j d | | j k S(   Ni
   (   R   R   R   R   (   R   R   R   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __le__†   s    c         C   sg   t  |  j | j ƒ } |  j | j k pf |  j | j k of |  j d | |  j | j d | | j k S(   Ni
   (   R   R   R   R   (   R   R   R   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __gt__‹   s    c         C   sg   t  |  j | j ƒ } |  j | j k pf |  j | j k of |  j d | |  j | j d | | j k S(   Ni
   (   R   R   R   R   (   R   R   R   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __ge__   s    c         C   s±   t  |  j | j ƒ } |  j d | |  j } | j d | | j } |  j | j k  su |  j | j k ry | | k  ry d S|  j | j k s© |  j | j k r­ | | k r­ d Sd S(   Ni
   iÿÿÿÿi   i    (   R   R   R   R   (   R   R   R   t   self_tictact	   tt_tictac(    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __cmp__•   s    44c         C   s
   |  | f S(   N(    (   R   R   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt
   __coerce__ž   s    c         C   s    t  r |  j Gd Gt ƒ  GHn  t S(   Ns   in eon(   t   g_EON_DEBUGt	   __class__t   whoamit   NotImplemented(   R   R   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __iadd__¡   s     c         C   s    t  r |  j Gd Gt ƒ  GHn  t S(   Ns   in eon(   R%   R&   R'   R(   (   R   R   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __add__¥   s     c         C   s    t  r |  j Gd Gt ƒ  GHn  t S(   Ns   in eon(   R%   R&   R'   R(   (   R   R   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __isub__©   s     c         C   s    t  r |  j Gd Gt ƒ  GHn  t S(   Ns   in eon(   R%   R&   R'   R(   (   R   R   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __sub__­   s     c         C   s    t  r |  j Gd Gt ƒ  GHn  |  S(   Ns   in eon(   R%   R&   R'   (   R   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __pos__±   s     c         C   s6   t  r |  j Gd Gt ƒ  GHn  t d t |  j ƒ ‚ d  S(   Ns   in eons#   illegal operation - (negation) for (   R%   R&   R'   t	   TypeErrort   str(   R   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __neg__µ   s     c         C   s    t  r |  j Gd Gt ƒ  GHn  t S(   Ns   in eon(   R%   R&   R'   R(   (   R   t
   multiplier(    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __imul__Á   s     c         C   s    t  r |  j Gd Gt ƒ  GHn  t S(   Ns   in eon(   R%   R&   R'   R(   (   R   R1   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __mul__Å   s     c         C   s    t  r |  j Gd Gt ƒ  GHn  t S(   Ns   in eon(   R%   R&   R'   R(   (   R   R1   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __rmul__É   s     c         C   s    t  r |  j Gd Gt ƒ  GHn  t S(   Ns   in eon(   R%   R&   R'   R(   (   R   R1   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __div__Í   s     c         C   s    t  r |  j Gd Gt ƒ  GHn  t S(   Ns   in eon(   R%   R&   R'   R(   (   R   t   divider(    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __idiv__Ñ   s     c         C   s    t  r |  j Gd Gt ƒ  GHn  t S(   Ns   in eon(   R%   R&   R'   R(   (   R   R6   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __rdiv__Õ   s     c         C   s    t  r |  j Gd Gt ƒ  GHn  t S(   Ns   in eon(   R%   R&   R'   R(   (   R   (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   __abs__Ù   s     c         C   s»  t  r |  j Gd Gt ƒ  GHn  | d  k r4 |  j } n  t | ƒ t d  ƒ k rÀ | d  k ra d } n  t | |  j ƒ } | |  j } | |  j d | |  j } d t	 |  j ƒ k r· d n d } nÁ | d  k rÕ d } n  t | |  j | j ƒ } | d |  j | d | j } | d |  j d | |  j | d | j d | | j } d t	 |  j ƒ k d t	 | j ƒ k k r{d n d } t
 | d d d | d | ƒ\ } } |  j | | | | ƒ S(	   Ns   in eoni   i
   t	   eon_deltat   eon_datei    R   (   i   i    (   R%   R&   R'   R   R   R   R   R   R   R/   t   fix_dst   make_instance(   R   R   t   factorR   R   R   t   eon_type(    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   linear_transformÝ   s&       	$ 	 >
6$c         C   sL   t  } | d  k r' |  | k  r' t } n  | d  k rH |  | k rH t } n  | S(   N(   R   R   R   (   R   t
   start_timet	   stop_timet   status(    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   between  s    		N("   t   __name__t
   __module__t   __doc__R   R   R(   R   R
   R   R   R   R   R   R   R   R   R    R#   R$   R)   R*   R+   R,   R-   R0   R2   R3   R4   R5   R7   R8   R9   R@   RD   (    (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyR      s:   5																										AN(    (   t
   eon_helperR   (    (    (    s,   /home/soft/smei/ucsd/gen/python/eon_class.pyt   <module>   s   
