OwlCyberSecurity - MANAGER
Edit File: dateops.pyc
� �t�ac @ s% d Z d d d d d d d g Z d d l m Z d d l m Z d d l m Z d d l m Z m Z d d l Z d d l Z d � Z d � Z d � Z d � Z d d � Z d d � Z d d � Z d d � Z d � Z d � Z d � Z d d � Z d � Z d d � Z d � Z d � Z d S( s Date/time Utilities t normalizeForIndext floatoffsett compareDateTimet differenceDateTimet timeRangesOverlapt normalizePeriodListt clipPeriodi����( t DateTime( t Timezone( t Period( t datet datetimeNc C s� t | t � s% t d | f � � n | j � } | j � rn | j t � | j d d d � | j d � | S| j � r~ | S| j � | Sd S( s� Normalize a L{DateTime} object for use in the Index. Convert to date-time in UTC. @param dt: a L{DateTime} object to normalize @return: the normalized DateTime s %r is not a DateTime instancei N( t isinstanceR t TypeErrort duplicatet isDateOnlyt setDateOnlyt Falset setHHMMSSt setTimezoneIDt Nonet floatingt adjustToUTC( t dt( ( s( /opt/cpanel-ccs/twistedcaldav/dateops.pyR ) s c C s� t | t � s% t d | f � � n | j � } | j � rn | j t � | j d d d � | j t � | S| j � r� | j t � | S| j � | Sd S( s0 Normalize a L{DateTime} object to UTC. s %r is not a DateTime instancei N( R R R R R R R R t setTimezoneUTCt TrueR R ( R ( ( s( /opt/cpanel-ccs/twistedcaldav/dateops.pyt normalizeToUTC@ s c C s_ t | t � s% t d | f � � n | j � } | j � sI | j � rM | S| j � | Sd S( s� Normalize a L{DateTime} object for use with the CalDAV expand option. Convert to date-time in UTC, leave date only and floating alone. @param dt: a L{DateTime} object to normalize @return: the normalized DateTime s %r is not a DateTime instanceN( R R R R R R R ( R ( ( s( /opt/cpanel-ccs/twistedcaldav/dateops.pyt normalizeForExpandU s c C sB | d k r t j } n | j � } | j | � | j t � | S( sb Apply the timezone offset to the supplied time, then force tz to utc. This gives the local date-time as if the local tz were UTC. It can be used in floating time comparisons with UTC date-times. @param dt: a L{DateTime} object to normalize @param pytz: a L{Timezone} object to apply offset from @return: the normalized DateTime N( R R t UTCTimezoneR t adjustTimezoneR R ( R t pytz( ( s( /opt/cpanel-ccs/twistedcaldav/dateops.pyR g s c C s/ | j � } | j | r | n | j � � | S( N( R t setTimezonet getTimezone( t dtadjustt dtcopyfromR ( ( s( /opt/cpanel-ccs/twistedcaldav/dateops.pyt adjustFloatingToTimezonez s c C si | j � r. | j � r. t | | | � } n. | j � r\ | j � r\ t | | | � } n | j | � S( N( R R# R ( t dt1t dt2t defaulttz( ( s( /opt/cpanel-ccs/twistedcaldav/dateops.pyR � s c C sd | j � r. | j � r. t | | | � } n. | j � r\ | j � r\ t | | | � } n | | S( N( R R# ( t startt endR&