File: //opt/alt/python37/lib/python3.7/site-packages/paste/util/__pycache__/datetimeutil.cpython-37.pyc
B
b�N�+ �
@ s� d Z ddlmZmZmZ ddlmZ ddlZddddd d
gZdd� Zd
d� Z dd� Z
dd� Zdd� Zedd�Z
ddddddddddddd�Zdd � Zd!d"d!d#d!d#d!d!d#d!d#d!d$�Zd%d&d'd(d)d*d+d,d-d.d/d0d$�Zd1Zd2d � Zd5d4d
�ZdS )6a.
Date, Time, and Timespan Parsing Utilities
This module contains parsing support to create "human friendly"
``datetime`` object parsing. The explicit goal of these routines is
to provide a multi-format date/time support not unlike that found in
Microsoft Excel. In most approaches, the input is very "strict" to
prevent errors -- however, this approach is much more liberal since we
are assuming the user-interface is parroting back the normalized value
and thus the user has immediate feedback if the data is not typed in
correctly.
``parse_date`` and ``normalize_date``
These functions take a value like '9 jan 2007' and returns either an
``date`` object, or an ISO 8601 formatted date value such
as '2007-01-09'. There is an option to provide an Oracle database
style output as well, ``09 JAN 2007``, but this is not the default.
This module always treats '/' delimiters as using US date order
(since the author's clients are US based), hence '1/9/2007' is
January 9th. Since this module treats the '-' as following
European order this supports both modes of data-entry; together
with immediate parroting back the result to the screen, the author
has found this approach to work well in pratice.
``parse_time`` and ``normalize_time``
These functions take a value like '1 pm' and returns either an
``time`` object, or an ISO 8601 formatted 24h clock time
such as '13:00'. There is an option to provide for US style time
values, '1:00 PM', however this is not the default.
``parse_datetime`` and ``normalize_datetime``
These functions take a value like '9 jan 2007 at 1 pm' and returns
either an ``datetime`` object, or an ISO 8601 formatted
return (without the T) such as '2007-01-09 13:00'. There is an
option to provide for Oracle / US style, '09 JAN 2007 @ 1:00 PM',
however this is not the default.
``parse_delta`` and ``normalize_delta``
These functions take a value like '1h 15m' and returns either an
``timedelta`` object, or an 2-decimal fixed-point
numerical value in hours, such as '1.25'. The rationale is to
support meeting or time-billing lengths, not to be an accurate
representation in mili-seconds. As such not all valid
``timedelta`` values will have a normalized representation.
� )� timedelta�time�date)� localtimeN�parse_timedelta�normalize_timedelta�
parse_time�normalize_time�
parse_date�normalize_datec C s y
t �| �S d S d S )N)�string�atoi)�val� r �H/opt/alt/python37/lib/python3.7/site-packages/paste/util/datetimeutil.py�_number@ s
r c C s� | sdS t �| �} d| kr:t| �} tt| �d| d d�S d| kpHd| k}d| kpXd| k}d| k}xd D ]}t �| |d
�} qhW t �| �} t �| �} d}d}| �� |r�t| � � �}|r�t| � � �}t
| �dkr�|s�t| � � �}t||d�S )
z1
returns a ``timedelta`` object, or None
N�.�<