Example #1
0
    def test_parsers_timezone_minute_offsets_roundtrip(self):
        # GH11708
        base = to_datetime("2013-01-01 00:00:00")
        dt_strings = [
            ("2013-01-01 05:45+0545", "Asia/Katmandu", "Timestamp('2013-01-01 05:45:00+0545', tz='Asia/Katmandu')"),
            ("2013-01-01 05:30+0530", "Asia/Kolkata", "Timestamp('2013-01-01 05:30:00+0530', tz='Asia/Kolkata')"),
        ]

        for dt_string, tz, dt_string_repr in dt_strings:
            dt_time = to_datetime(dt_string)
            self.assertEqual(base, dt_time)
            converted_time = dt_time.tz_localize("UTC").tz_convert(tz)
            self.assertEqual(dt_string_repr, repr(converted_time))
Example #2
0
    def test_parsers_timezone_minute_offsets_roundtrip(self):
        # GH11708
        base = to_datetime("2013-01-01 00:00:00")
        dt_strings = [
            ('2013-01-01 05:45+0545', "Asia/Katmandu",
             "Timestamp('2013-01-01 05:45:00+0545', tz='Asia/Katmandu')"),
            ('2013-01-01 05:30+0530', "Asia/Kolkata",
             "Timestamp('2013-01-01 05:30:00+0530', tz='Asia/Kolkata')")
        ]

        for dt_string, tz, dt_string_repr in dt_strings:
            dt_time = to_datetime(dt_string)
            self.assertEqual(base, dt_time)
            converted_time = dt_time.tz_localize('UTC').tz_convert(tz)
            self.assertEqual(dt_string_repr, repr(converted_time))
Example #3
0
    def test_parsers_dayfirst_yearfirst(self):
        # str : dayfirst, yearfirst, expected
        cases = {'10-11-12': [(False, False, datetime.datetime(2012, 10, 11)),
                              (True, False, datetime.datetime(2012, 11, 10)),
                              (False, True, datetime.datetime(2010, 11, 12)),
                              (True, True, datetime.datetime(2010, 11, 12))],
                 '20/12/21': [(False, False, datetime.datetime(2021, 12, 20)),
                              (True, False, datetime.datetime(2021, 12, 20)),
                              (False, True, datetime.datetime(2020, 12, 21)),
                              (True, True, datetime.datetime(2020, 12, 21))]}

        tm._skip_if_no_dateutil()
        from dateutil.parser import parse
        for date_str, values in compat.iteritems(cases):
            for dayfirst, yearfirst ,expected in values:
                result1, _, _ = tools.parse_time_string(date_str, dayfirst=dayfirst,
                                                        yearfirst=yearfirst)

                result2 = to_datetime(date_str, dayfirst=dayfirst,
                                      yearfirst=yearfirst)

                result3 = DatetimeIndex([date_str], dayfirst=dayfirst,
                                        yearfirst=yearfirst)[0]

                # Timestamp doesn't support dayfirst and yearfirst

                self.assertEqual(result1, expected)
                self.assertEqual(result2, expected)
                self.assertEqual(result3, expected)

                # compare with dateutil result
                dateutil_result = parse(date_str, dayfirst=dayfirst, yearfirst=yearfirst)
                self.assertEqual(dateutil_result, expected)
Example #4
0
    def test_parsers_timestring(self):
        tm._skip_if_no_dateutil()
        from dateutil.parser import parse

        # must be the same as dateutil result
        cases = {'10:15': (parse('10:15'), datetime.datetime(1, 1, 1, 10, 15)),
                 '9:05': (parse('9:05'), datetime.datetime(1, 1, 1, 9, 5)) }

        for date_str, (exp_now, exp_def) in compat.iteritems(cases):
            result1, _, _ = tools.parse_time_string(date_str)
            result2 = to_datetime(date_str)
            result3 = to_datetime([date_str])
            result4 = Timestamp(date_str)
            result5 = DatetimeIndex([date_str])[0]
            # parse time string return time string based on default date
            # others are not, and can't be changed because it is used in
            # time series plot
            self.assertEqual(result1, exp_def)
            self.assertEqual(result2, exp_now)
            self.assertEqual(result3, exp_now)
            self.assertEqual(result4, exp_now)
            self.assertEqual(result5, exp_now)
Example #5
0
    def test_parsers_timestring(self):
        tm._skip_if_no_dateutil()
        from dateutil.parser import parse

        # must be the same as dateutil result
        cases = {'10:15': (parse('10:15'), datetime.datetime(1, 1, 1, 10, 15)),
                 '9:05': (parse('9:05'), datetime.datetime(1, 1, 1, 9, 5))}

        for date_str, (exp_now, exp_def) in compat.iteritems(cases):
            result1, _, _ = tools.parse_time_string(date_str)
            result2 = to_datetime(date_str)
            result3 = to_datetime([date_str])
            result4 = Timestamp(date_str)
            result5 = DatetimeIndex([date_str])[0]
            # parse time string return time string based on default date
            # others are not, and can't be changed because it is used in
            # time series plot
            self.assertEqual(result1, exp_def)
            self.assertEqual(result2, exp_now)
            self.assertEqual(result3, exp_now)
            self.assertEqual(result4, exp_now)
            self.assertEqual(result5, exp_now)
Example #6
0
    def test_parsers_dayfirst_yearfirst(self):
        # str : dayfirst, yearfirst, expected
        cases = {
            '10-11-12': [(False, False, datetime.datetime(2012, 10, 11)),
                         (True, False, datetime.datetime(2012, 11, 10)),
                         (False, True, datetime.datetime(2010, 11, 12)),
                         (True, True, datetime.datetime(2010, 11, 12))],
            '20/12/21': [(False, False, datetime.datetime(2021, 12, 20)),
                         (True, False, datetime.datetime(2021, 12, 20)),
                         (False, True, datetime.datetime(2020, 12, 21)),
                         (True, True, datetime.datetime(2020, 12, 21))]
        }

        tm._skip_if_no_dateutil()
        from dateutil.parser import parse
        for date_str, values in compat.iteritems(cases):
            for dayfirst, yearfirst, expected in values:
                result1, _, _ = tools.parse_time_string(date_str,
                                                        dayfirst=dayfirst,
                                                        yearfirst=yearfirst)

                result2 = to_datetime(date_str,
                                      dayfirst=dayfirst,
                                      yearfirst=yearfirst)

                result3 = DatetimeIndex([date_str],
                                        dayfirst=dayfirst,
                                        yearfirst=yearfirst)[0]

                # Timestamp doesn't support dayfirst and yearfirst

                self.assertEqual(result1, expected)
                self.assertEqual(result2, expected)
                self.assertEqual(result3, expected)

                # compare with dateutil result
                dateutil_result = parse(date_str,
                                        dayfirst=dayfirst,
                                        yearfirst=yearfirst)
                self.assertEqual(dateutil_result, expected)
Example #7
0
    def test_parsers(self):
        cases = {
            '2011-01-01': datetime.datetime(2011, 1, 1),
            '2Q2005': datetime.datetime(2005, 4, 1),
            '2Q05': datetime.datetime(2005, 4, 1),
            '2005Q1': datetime.datetime(2005, 1, 1),
            '05Q1': datetime.datetime(2005, 1, 1),
            '2011Q3': datetime.datetime(2011, 7, 1),
            '11Q3': datetime.datetime(2011, 7, 1),
            '3Q2011': datetime.datetime(2011, 7, 1),
            '3Q11': datetime.datetime(2011, 7, 1),

            # quarterly without space
            '2000Q4': datetime.datetime(2000, 10, 1),
            '00Q4': datetime.datetime(2000, 10, 1),
            '4Q2000': datetime.datetime(2000, 10, 1),
            '4Q00': datetime.datetime(2000, 10, 1),
            '2000q4': datetime.datetime(2000, 10, 1),
            '2000-Q4': datetime.datetime(2000, 10, 1),
            '00-Q4': datetime.datetime(2000, 10, 1),
            '4Q-2000': datetime.datetime(2000, 10, 1),
            '4Q-00': datetime.datetime(2000, 10, 1),
            '2000q4': datetime.datetime(2000, 10, 1),
            '00q4': datetime.datetime(2000, 10, 1),
            '2005': datetime.datetime(2005, 1, 1),
            '2005-11': datetime.datetime(2005, 11, 1),
            '2005 11': datetime.datetime(2005, 11, 1),
            '11-2005': datetime.datetime(2005, 11, 1),
            '11 2005': datetime.datetime(2005, 11, 1),
            '200511': datetime.datetime(2020, 5, 11),
            '20051109': datetime.datetime(2005, 11, 9),
            '20051109 10:15': datetime.datetime(2005, 11, 9, 10, 15),
            '20051109 08H': datetime.datetime(2005, 11, 9, 8, 0),
            '2005-11-09 10:15': datetime.datetime(2005, 11, 9, 10, 15),
            '2005-11-09 08H': datetime.datetime(2005, 11, 9, 8, 0),
            '2005/11/09 10:15': datetime.datetime(2005, 11, 9, 10, 15),
            '2005/11/09 08H': datetime.datetime(2005, 11, 9, 8, 0),
            "Thu Sep 25 10:36:28 2003":
            datetime.datetime(2003, 9, 25, 10, 36, 28),
            "Thu Sep 25 2003": datetime.datetime(2003, 9, 25),
            "Sep 25 2003": datetime.datetime(2003, 9, 25),
            "January 1 2014": datetime.datetime(2014, 1, 1),

            # GH 10537
            '2014-06': datetime.datetime(2014, 6, 1),
            '06-2014': datetime.datetime(2014, 6, 1),
            '2014-6': datetime.datetime(2014, 6, 1),
            '6-2014': datetime.datetime(2014, 6, 1),
        }

        for date_str, expected in compat.iteritems(cases):
            result1, _, _ = tools.parse_time_string(date_str)
            result2 = to_datetime(date_str)
            result3 = to_datetime([date_str])
            result4 = to_datetime(np.array([date_str], dtype=object))
            result5 = Timestamp(date_str)
            result6 = DatetimeIndex([date_str])[0]
            result7 = date_range(date_str, freq='S', periods=1)
            self.assertEqual(result1, expected)
            self.assertEqual(result2, expected)
            self.assertEqual(result3, expected)
            self.assertEqual(result4, expected)
            self.assertEqual(result5, expected)
            self.assertEqual(result6, expected)
            self.assertEqual(result7, expected)

        # NaT
        result1, _, _ = tools.parse_time_string('NaT')
        result2 = to_datetime('NaT')
        result3 = Timestamp('NaT')
        result4 = DatetimeIndex(['NaT'])[0]
        self.assertTrue(result1 is tslib.NaT)
        self.assertTrue(result1 is tslib.NaT)
        self.assertTrue(result1 is tslib.NaT)
        self.assertTrue(result1 is tslib.NaT)
Example #8
0
    def test_parsers(self):
        cases = {
            "2011-01-01": datetime.datetime(2011, 1, 1),
            "2Q2005": datetime.datetime(2005, 4, 1),
            "2Q05": datetime.datetime(2005, 4, 1),
            "2005Q1": datetime.datetime(2005, 1, 1),
            "05Q1": datetime.datetime(2005, 1, 1),
            "2011Q3": datetime.datetime(2011, 7, 1),
            "11Q3": datetime.datetime(2011, 7, 1),
            "3Q2011": datetime.datetime(2011, 7, 1),
            "3Q11": datetime.datetime(2011, 7, 1),
            # quarterly without space
            "2000Q4": datetime.datetime(2000, 10, 1),
            "00Q4": datetime.datetime(2000, 10, 1),
            "4Q2000": datetime.datetime(2000, 10, 1),
            "4Q00": datetime.datetime(2000, 10, 1),
            "2000q4": datetime.datetime(2000, 10, 1),
            "2000-Q4": datetime.datetime(2000, 10, 1),
            "00-Q4": datetime.datetime(2000, 10, 1),
            "4Q-2000": datetime.datetime(2000, 10, 1),
            "4Q-00": datetime.datetime(2000, 10, 1),
            "2000q4": datetime.datetime(2000, 10, 1),
            "00q4": datetime.datetime(2000, 10, 1),
            "2005": datetime.datetime(2005, 1, 1),
            "2005-11": datetime.datetime(2005, 11, 1),
            "2005 11": datetime.datetime(2005, 11, 1),
            "11-2005": datetime.datetime(2005, 11, 1),
            "11 2005": datetime.datetime(2005, 11, 1),
            "200511": datetime.datetime(2020, 5, 11),
            "20051109": datetime.datetime(2005, 11, 9),
            "20051109 10:15": datetime.datetime(2005, 11, 9, 10, 15),
            "20051109 08H": datetime.datetime(2005, 11, 9, 8, 0),
            "2005-11-09 10:15": datetime.datetime(2005, 11, 9, 10, 15),
            "2005-11-09 08H": datetime.datetime(2005, 11, 9, 8, 0),
            "2005/11/09 10:15": datetime.datetime(2005, 11, 9, 10, 15),
            "2005/11/09 08H": datetime.datetime(2005, 11, 9, 8, 0),
            "Thu Sep 25 10:36:28 2003": datetime.datetime(2003, 9, 25, 10, 36, 28),
            "Thu Sep 25 2003": datetime.datetime(2003, 9, 25),
            "Sep 25 2003": datetime.datetime(2003, 9, 25),
            "January 1 2014": datetime.datetime(2014, 1, 1),
            # GH 10537
            "2014-06": datetime.datetime(2014, 6, 1),
            "06-2014": datetime.datetime(2014, 6, 1),
            "2014-6": datetime.datetime(2014, 6, 1),
            "6-2014": datetime.datetime(2014, 6, 1),
        }

        for date_str, expected in compat.iteritems(cases):
            result1, _, _ = tools.parse_time_string(date_str)
            result2 = to_datetime(date_str)
            result3 = to_datetime([date_str])
            result4 = to_datetime(np.array([date_str], dtype=object))
            result5 = Timestamp(date_str)
            result6 = DatetimeIndex([date_str])[0]
            result7 = date_range(date_str, freq="S", periods=1)
            self.assertEqual(result1, expected)
            self.assertEqual(result2, expected)
            self.assertEqual(result3, expected)
            self.assertEqual(result4, expected)
            self.assertEqual(result5, expected)
            self.assertEqual(result6, expected)
            self.assertEqual(result7, expected)

        # NaT
        result1, _, _ = tools.parse_time_string("NaT")
        result2 = to_datetime("NaT")
        result3 = Timestamp("NaT")
        result4 = DatetimeIndex(["NaT"])[0]
        self.assertTrue(result1 is tslib.NaT)
        self.assertTrue(result1 is tslib.NaT)
        self.assertTrue(result1 is tslib.NaT)
        self.assertTrue(result1 is tslib.NaT)
Example #9
0
    def test_parsers(self):
        cases = {'2011-01-01': datetime.datetime(2011, 1, 1),
                 '2Q2005': datetime.datetime(2005, 4, 1),
                 '2Q05': datetime.datetime(2005, 4, 1),
                 '2005Q1': datetime.datetime(2005, 1, 1),
                 '05Q1': datetime.datetime(2005, 1, 1),
                 '2011Q3': datetime.datetime(2011, 7, 1),
                 '11Q3': datetime.datetime(2011, 7, 1),
                 '3Q2011': datetime.datetime(2011, 7, 1),
                 '3Q11': datetime.datetime(2011, 7, 1),

                 # quarterly without space
                 '2000Q4': datetime.datetime(2000, 10, 1),
                 '00Q4': datetime.datetime(2000, 10, 1),
                 '4Q2000': datetime.datetime(2000, 10, 1),
                 '4Q00': datetime.datetime(2000, 10, 1),
                 '2000q4': datetime.datetime(2000, 10, 1),

                 '2000-Q4': datetime.datetime(2000, 10, 1),
                 '00-Q4': datetime.datetime(2000, 10, 1),
                 '4Q-2000': datetime.datetime(2000, 10, 1),
                 '4Q-00': datetime.datetime(2000, 10, 1),

                 '2000q4': datetime.datetime(2000, 10, 1),
                 '00q4': datetime.datetime(2000, 10, 1),

                 '2005': datetime.datetime(2005, 1, 1),
                 '2005-11': datetime.datetime(2005, 11, 1),
                 '2005 11': datetime.datetime(2005, 11, 1),
                 '11-2005': datetime.datetime(2005, 11, 1),
                 '11 2005': datetime.datetime(2005, 11, 1),
                 '200511': datetime.datetime(2020, 5, 11),
                 '20051109': datetime.datetime(2005, 11, 9),

                 '20051109 10:15': datetime.datetime(2005, 11, 9, 10, 15),
                 '20051109 08H': datetime.datetime(2005, 11, 9, 8, 0),

                 '2005-11-09 10:15': datetime.datetime(2005, 11, 9, 10, 15),
                 '2005-11-09 08H': datetime.datetime(2005, 11, 9, 8, 0),
                 '2005/11/09 10:15': datetime.datetime(2005, 11, 9, 10, 15),
                 '2005/11/09 08H': datetime.datetime(2005, 11, 9, 8, 0),

                 "Thu Sep 25 10:36:28 2003": datetime.datetime(2003, 9, 25, 10, 36, 28),
                 "Thu Sep 25 2003": datetime.datetime(2003, 9, 25),
                 "Sep 25 2003": datetime.datetime(2003, 9, 25),
                 "January 1 2014": datetime.datetime(2014, 1, 1),

                 # GH 10537
                 '2014-06': datetime.datetime(2014, 6, 1),
                 '06-2014': datetime.datetime(2014, 6, 1),
                 '2014-6': datetime.datetime(2014, 6, 1),
                 '6-2014': datetime.datetime(2014, 6, 1),
                 }

        for date_str, expected in compat.iteritems(cases):
            result1, _, _ = tools.parse_time_string(date_str)
            result2 = to_datetime(date_str)
            result3 = to_datetime([date_str])
            result4 = to_datetime(np.array([date_str], dtype=object))
            result5 = Timestamp(date_str)
            result6 = DatetimeIndex([date_str])[0]
            result7 = date_range(date_str, freq='S', periods=1)
            self.assertEqual(result1, expected)
            self.assertEqual(result2, expected)
            self.assertEqual(result3, expected)
            self.assertEqual(result4, expected)
            self.assertEqual(result5, expected)
            self.assertEqual(result6, expected)
            self.assertEqual(result7, expected)

        # NaT
        result1, _, _ = tools.parse_time_string('NaT')
        result2 = to_datetime('NaT')
        result3 = Timestamp('NaT')
        result4 = DatetimeIndex(['NaT'])[0]
        self.assertTrue(result1 is tslib.NaT)
        self.assertTrue(result1 is tslib.NaT)
        self.assertTrue(result1 is tslib.NaT)
        self.assertTrue(result1 is tslib.NaT)
Example #10
0
    def test_parsers(self):

        # https://github.com/dateutil/dateutil/issues/217
        import dateutil
        yearfirst = dateutil.__version__ >= LooseVersion('2.5.0')

        cases = {'2011-01-01': datetime.datetime(2011, 1, 1),
                 '2Q2005': datetime.datetime(2005, 4, 1),
                 '2Q05': datetime.datetime(2005, 4, 1),
                 '2005Q1': datetime.datetime(2005, 1, 1),
                 '05Q1': datetime.datetime(2005, 1, 1),
                 '2011Q3': datetime.datetime(2011, 7, 1),
                 '11Q3': datetime.datetime(2011, 7, 1),
                 '3Q2011': datetime.datetime(2011, 7, 1),
                 '3Q11': datetime.datetime(2011, 7, 1),

                 # quarterly without space
                 '2000Q4': datetime.datetime(2000, 10, 1),
                 '00Q4': datetime.datetime(2000, 10, 1),
                 '4Q2000': datetime.datetime(2000, 10, 1),
                 '4Q00': datetime.datetime(2000, 10, 1),
                 '2000q4': datetime.datetime(2000, 10, 1),
                 '2000-Q4': datetime.datetime(2000, 10, 1),
                 '00-Q4': datetime.datetime(2000, 10, 1),
                 '4Q-2000': datetime.datetime(2000, 10, 1),
                 '4Q-00': datetime.datetime(2000, 10, 1),
                 '00q4': datetime.datetime(2000, 10, 1),
                 '2005': datetime.datetime(2005, 1, 1),
                 '2005-11': datetime.datetime(2005, 11, 1),
                 '2005 11': datetime.datetime(2005, 11, 1),
                 '11-2005': datetime.datetime(2005, 11, 1),
                 '11 2005': datetime.datetime(2005, 11, 1),
                 '200511': datetime.datetime(2020, 5, 11),
                 '20051109': datetime.datetime(2005, 11, 9),
                 '20051109 10:15': datetime.datetime(2005, 11, 9, 10, 15),
                 '20051109 08H': datetime.datetime(2005, 11, 9, 8, 0),
                 '2005-11-09 10:15': datetime.datetime(2005, 11, 9, 10, 15),
                 '2005-11-09 08H': datetime.datetime(2005, 11, 9, 8, 0),
                 '2005/11/09 10:15': datetime.datetime(2005, 11, 9, 10, 15),
                 '2005/11/09 08H': datetime.datetime(2005, 11, 9, 8, 0),
                 "Thu Sep 25 10:36:28 2003": datetime.datetime(2003, 9, 25, 10,
                                                               36, 28),
                 "Thu Sep 25 2003": datetime.datetime(2003, 9, 25),
                 "Sep 25 2003": datetime.datetime(2003, 9, 25),
                 "January 1 2014": datetime.datetime(2014, 1, 1),

                 # GH 10537
                 '2014-06': datetime.datetime(2014, 6, 1),
                 '06-2014': datetime.datetime(2014, 6, 1),
                 '2014-6': datetime.datetime(2014, 6, 1),
                 '6-2014': datetime.datetime(2014, 6, 1),

                 '20010101 12': datetime.datetime(2001, 1, 1, 12),
                 '20010101 1234': datetime.datetime(2001, 1, 1, 12, 34),
                 '20010101 123456': datetime.datetime(2001, 1, 1, 12, 34, 56),
                 }

        for date_str, expected in compat.iteritems(cases):
            result1, _, _ = tools.parse_time_string(date_str,
                                                    yearfirst=yearfirst)
            result2 = to_datetime(date_str, yearfirst=yearfirst)
            result3 = to_datetime([date_str], yearfirst=yearfirst)
            # result5 is used below
            result4 = to_datetime(np.array([date_str], dtype=object),
                                  yearfirst=yearfirst)
            result6 = DatetimeIndex([date_str], yearfirst=yearfirst)
            # result7 is used below
            result8 = DatetimeIndex(Index([date_str]), yearfirst=yearfirst)
            result9 = DatetimeIndex(Series([date_str]), yearfirst=yearfirst)

            for res in [result1, result2]:
                self.assertEqual(res, expected)
            for res in [result3, result4, result6, result8, result9]:
                exp = DatetimeIndex([pd.Timestamp(expected)])
                tm.assert_index_equal(res, exp)

            # these really need to have yearfist, but we don't support
            if not yearfirst:
                result5 = Timestamp(date_str)
                self.assertEqual(result5, expected)
                result7 = date_range(date_str, freq='S', periods=1,
                                     yearfirst=yearfirst)
                self.assertEqual(result7, expected)

        # NaT
        result1, _, _ = tools.parse_time_string('NaT')
        result2 = to_datetime('NaT')
        result3 = Timestamp('NaT')
        result4 = DatetimeIndex(['NaT'])[0]
        self.assertTrue(result1 is tslib.NaT)
        self.assertTrue(result1 is tslib.NaT)
        self.assertTrue(result1 is tslib.NaT)
        self.assertTrue(result1 is tslib.NaT)
Example #11
0
    def test_parsers_dayfirst_yearfirst(self):
        tm._skip_if_no_dateutil()

        # OK
        # 2.5.1 10-11-12   [dayfirst=0, yearfirst=0] -> 2012-10-11 00:00:00
        # 2.5.2 10-11-12   [dayfirst=0, yearfirst=1] -> 2012-10-11 00:00:00
        # 2.5.3 10-11-12   [dayfirst=0, yearfirst=0] -> 2012-10-11 00:00:00

        # OK
        # 2.5.1 10-11-12   [dayfirst=0, yearfirst=1] -> 2010-11-12 00:00:00
        # 2.5.2 10-11-12   [dayfirst=0, yearfirst=1] -> 2010-11-12 00:00:00
        # 2.5.3 10-11-12   [dayfirst=0, yearfirst=1] -> 2010-11-12 00:00:00

        # bug fix in 2.5.2
        # 2.5.1 10-11-12   [dayfirst=1, yearfirst=1] -> 2010-11-12 00:00:00
        # 2.5.2 10-11-12   [dayfirst=1, yearfirst=1] -> 2010-12-11 00:00:00
        # 2.5.3 10-11-12   [dayfirst=1, yearfirst=1] -> 2010-12-11 00:00:00

        # OK
        # 2.5.1 10-11-12   [dayfirst=1, yearfirst=0] -> 2012-11-10 00:00:00
        # 2.5.2 10-11-12   [dayfirst=1, yearfirst=0] -> 2012-11-10 00:00:00
        # 2.5.3 10-11-12   [dayfirst=1, yearfirst=0] -> 2012-11-10 00:00:00

        # OK
        # 2.5.1 20/12/21   [dayfirst=0, yearfirst=0] -> 2021-12-20 00:00:00
        # 2.5.2 20/12/21   [dayfirst=0, yearfirst=0] -> 2021-12-20 00:00:00
        # 2.5.3 20/12/21   [dayfirst=0, yearfirst=0] -> 2021-12-20 00:00:00

        # OK
        # 2.5.1 20/12/21   [dayfirst=0, yearfirst=1] -> 2020-12-21 00:00:00
        # 2.5.2 20/12/21   [dayfirst=0, yearfirst=1] -> 2020-12-21 00:00:00
        # 2.5.3 20/12/21   [dayfirst=0, yearfirst=1] -> 2020-12-21 00:00:00

        # revert of bug in 2.5.2
        # 2.5.1 20/12/21   [dayfirst=1, yearfirst=1] -> 2020-12-21 00:00:00
        # 2.5.2 20/12/21   [dayfirst=1, yearfirst=1] -> month must be in 1..12
        # 2.5.3 20/12/21   [dayfirst=1, yearfirst=1] -> 2020-12-21 00:00:00

        # OK
        # 2.5.1 20/12/21   [dayfirst=1, yearfirst=0] -> 2021-12-20 00:00:00
        # 2.5.2 20/12/21   [dayfirst=1, yearfirst=0] -> 2021-12-20 00:00:00
        # 2.5.3 20/12/21   [dayfirst=1, yearfirst=0] -> 2021-12-20 00:00:00

        import dateutil
        is_lt_253 = dateutil.__version__ < LooseVersion('2.5.3')

        # str : dayfirst, yearfirst, expected
        cases = {'10-11-12': [(False, False,
                               datetime.datetime(2012, 10, 11)),
                              (True, False,
                               datetime.datetime(2012, 11, 10)),
                              (False, True,
                               datetime.datetime(2010, 11, 12)),
                              (True, True,
                               datetime.datetime(2010, 12, 11))],
                 '20/12/21': [(False, False,
                               datetime.datetime(2021, 12, 20)),
                              (True, False,
                               datetime.datetime(2021, 12, 20)),
                              (False, True,
                               datetime.datetime(2020, 12, 21)),
                              (True, True,
                               datetime.datetime(2020, 12, 21))]}

        from dateutil.parser import parse
        for date_str, values in compat.iteritems(cases):
            for dayfirst, yearfirst, expected in values:

                # odd comparisons across version
                # let's just skip
                if dayfirst and yearfirst and is_lt_253:
                    continue

                # compare with dateutil result
                dateutil_result = parse(date_str, dayfirst=dayfirst,
                                        yearfirst=yearfirst)
                self.assertEqual(dateutil_result, expected)

                result1, _, _ = tools.parse_time_string(date_str,
                                                        dayfirst=dayfirst,
                                                        yearfirst=yearfirst)

                # we don't support dayfirst/yearfirst here:
                if not dayfirst and not yearfirst:
                    result2 = Timestamp(date_str)
                    self.assertEqual(result2, expected)

                result3 = to_datetime(date_str, dayfirst=dayfirst,
                                      yearfirst=yearfirst)

                result4 = DatetimeIndex([date_str], dayfirst=dayfirst,
                                        yearfirst=yearfirst)[0]

                self.assertEqual(result1, expected)
                self.assertEqual(result3, expected)
                self.assertEqual(result4, expected)