types.py 967 Bytes
Newer Older
Jerome Mariette's avatar
Jerome Mariette committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#
# Copyright (C) 2012 INRA
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

Jerome Mariette's avatar
Jerome Mariette committed
18
import argparse
Jerome Mariette's avatar
Jerome Mariette committed
19
import datetime
20
from jflow.config_reader import JFlowConfigReader
Jerome Mariette's avatar
Jerome Mariette committed
21

Jerome Mariette's avatar
Jerome Mariette committed
22

Jerome Mariette's avatar
Jerome Mariette committed
23
def date(datestr):
24
    try:
25
        return datetime.datetime.strptime(datestr, JFlowConfigReader().get_date_format())
26
27
    except:
        raise argparse.ArgumentTypeError("'" + datestr + "' is an invalid date!")
28