3
ÎédË  ã               @   s>   d Z ddlZddlZddlmZmZmZmZ G dd„ dƒZdS )a]  
http://yaml.org/type/timestamp.html specifies the regexp to use
for datetime.date and datetime.datetime construction. Date is simple
but datetime can have 'T' or 't' as well as 'Z' or a timezone offset (in
hours and minutes). This information was originally used to create
a UTC datetime and then discarded

examples from the above:

canonical:        2001-12-15T02:59:43.1Z
valid iso8601:    2001-12-14t21:59:43.10-05:00
space separated:  2001-12-14 21:59:43.10 -5
no time zone (Z): 2001-12-15 2:59:43.10
date (00:00:00Z): 2002-12-14

Please note that a fraction can only be included if not equal to 0

é    Né   )Ú
round_tripÚdedentÚround_trip_loadÚround_trip_dumpc               @   s|   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚTestDateTimec             C   s   d}d}t ||ƒ d S )Nz
        - 2011-10-02
        )r   )ÚselfÚinpÚexp© r   úY/var/www/html/virt/lib64/python3.6/site-packages/srsly/tests/ruamel_yaml/test_datetime.pyÚtest_date_only   s    zTestDateTime.test_date_onlyc             C   s   d}d}t ||ƒ d S )Nz)
        - 2011-10-02 16:45:00.0
        z'
        - 2011-10-02 16:45:00
        )r   )r   r	   r
   r   r   r   Útest_zero_fraction&   s    zTestDateTime.test_zero_fractionc             C   s   d}d}t ||ƒ d S )Na  
        - 2011-10-02 16:45:00.1234      # expand with zeros
        - 2011-10-02 16:45:00.123456
        - 2011-10-02 16:45:00.12345612  # round to microseconds
        - 2011-10-02 16:45:00.1234565   # round up
        - 2011-10-02 16:45:00.12345678  # round up
        a  
        - 2011-10-02 16:45:00.123400    # expand with zeros
        - 2011-10-02 16:45:00.123456
        - 2011-10-02 16:45:00.123456    # round to microseconds
        - 2011-10-02 16:45:00.123457    # round up
        - 2011-10-02 16:45:00.123457    # round up
        )r   )r   r	   r
   r   r   r   Útest_long_fraction/   s    zTestDateTime.test_long_fractionc             C   s   d}d}t ||ƒ d S )Nz*
        - 2011-10-02T16:45:00.1Z
        z/
        - 2011-10-02T16:45:00.100000Z
        )r   )r   r	   r
   r   r   r   Útest_canonical@   s    zTestDateTime.test_canonicalc             C   s   d}d}t ||ƒ d S )Nz*
        - 2011-10-02T11:45:00 -5
        z)
        - 2011-10-02T11:45:00-5
        )r   )r   r	   r
   r   r   r   Útest_spaced_timezoneI   s    z!TestDateTime.test_spaced_timezonec             C   s   t dƒ d S )Nz‘
        - 2011-10-02T11:45:00-5
        - 2011-10-02 11:45:00-5
        - 2011-10-02T11:45:00-05:00
        - 2011-10-02 11:45:00-05:00
        )r   )r   r   r   r   Útest_normal_timezoneR   s    z!TestDateTime.test_normal_timezonec             C   s   d}d}t ||ƒ d S )Nz&
        - 2011-10-02 6:45:00
        z'
        - 2011-10-02 06:45:00
        )r   )r   r	   r
   r   r   r   Útest_no_timezone\   s    zTestDateTime.test_no_timezonec             C   s   d}d}t ||ƒ d S )Nz'
        - 2011-10-02T16:45:00
        )r   )r   r	   r
   r   r   r   Útest_explicit_Te   s    zTestDateTime.test_explicit_Tc             C   s   d}d}t ||ƒ d S )Nz'
        - 2011-10-02t16:45:00
        z'
        - 2011-10-02T16:45:00
        )r   )r   r	   r
   r   r   r   Útest_explicit_tn   s    zTestDateTime.test_explicit_tc             C   s   d}d}t ||ƒ d S )Nz)
        - 2011-10-02   16:45:00
        z'
        - 2011-10-02 16:45:00
        )r   )r   r	   r
   r   r   r   Útest_no_T_multi_spacew   s    z"TestDateTime.test_no_T_multi_spacec             C   s   t dƒ d S )Nz-
        - 2011-10-02T15:45:00+01:00
        )r   )r   r   r   r   Útest_iso€   s    zTestDateTime.test_isoc             C   s   t dƒ d S )Nz)
        - 2011-10-02T15:45:00+0
        )r   )r   r   r   r   Útest_zero_tz‡   s    zTestDateTime.test_zero_tzc             C   s   t dƒ d S )Nz*
        dt: 2016-08-19T22:45:47Z
        )r   )r   r   r   r   Útest_issue_45Ž   s    zTestDateTime.test_issue_45c             C   s*   t dƒ}tjt|ƒƒ}t|ƒ|ks&t‚d S )Nz)        foo: 2016-10-12T12:34:56
        )r   ÚcopyÚdeepcopyr   r   ÚAssertionError)r   ÚxÚdatar   r   r   Útest_deepcopy_datestring•   s    z%TestDateTime.test_deepcopy_datestringN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s   				
				r   )	Ú__doc__r   ZpytestZ	roundtripr   r   r   r   r   r   r   r   r   Ú<module>   s   