Repository: dateutil/dateutil (Python)

Issue:
Parser doesn't use dayfirst and yearfirst when no separator
It always uses the format: YYMMDD or YYYYMMDD despite if yearfirst is set to False or dayfirst is set to True.
I think it should try:
- yearfirst=False and dayfirst=False: MMDDYY
- yearfirst=True and dayfirst=False: YYMMDD
- yearfirst=True and dayfirst=True: YYDDMM
- yearfirst=False and dayfirst=True: DDMMYY

yearfirst bug fixed?
xref https://github.com/pydata/pandas/issues/12611

I guess this was a bug in < 2.5?

```
In [1]: import dateutil.parser

In [2]: p = dateutil.parser.parser()

In [3]: p.parse(StringIO('090131'), dayfirst=False, yearfirst=False)
Out[3]: datetime.datetime(2009, 1, 31, 0, 0)

In [4]: dateutil.__version__
Out[4]: '2.4.1'
```

```
In [1]: import dateutil.parser
In [3]: p = dateutil.parser.parser()

In [4]: p.parse(StringIO('090131'), dayfirst=False, yearfirst=False)
Out[4]: datetime.datetime(2031, 9, 1, 0, 0)

In [5]: p.parse(StringIO('090131'), dayfirst=False, yearfirst=True)
Out[5]: datetime.datetime(2009, 1, 31, 0, 0)

In [5]: import dateutil

In [6]: dateutil.__version__
Out[6]: '2.5.0'
```



Hints:
Yes, good point. I think that this is easy enough to address. The relevant section of `parser` is [here](https://github.com/dateutil/dateutil/blob/master/dateutil/parser.py#L669) in case anyone wants to fix it before I get around to it.

It seems that this issue as been partly fixed in master.

yearfirst=False and dayfirst=False return the correct output
yearfirst=True and dayfirst=False return the correct output
yearfirst=False and dayfirst=True return the correct output
But yearfirst=True and dayfirst=True give the same output as yearfirst=True and dayfirst=False (YYMMDD) instead of YYDDMM

If you confirm me that it's not the expected behavior I can try to make a fix.

According to `git bisect`, this was fixed in [this commit](https://github.com/dateutil/dateutil/commit/fc6962540e2), which I believe was part of #130. I'll add some tests to make sure it stays fixed.

This is at least partially issue #81.

@pganssle great thanks! didn't even realize that we had this edge case until some tests broke :)

anyhow, #214 is related here.


Patch:
diff --git a/dateutil/parser.py b/dateutil/parser.py
--- a/dateutil/parser.py
+++ b/dateutil/parser.py
@@ -464,7 +464,10 @@ def resolve_ymd(self, mstridx, yearfirst, dayfirst):
                     self.find_probable_year_index(_timelex.split(self.tzstr)) == 0 or \
                    (yearfirst and self[1] <= 12 and self[2] <= 31):
                     # 99-01-01
-                    year, month, day = self
+                    if dayfirst:
+                        year, day, month = self
+                    else:
+                        year, month, day = self
                 elif self[0] > 12 or (dayfirst and self[1] <= 12):
                     # 13-01-01
                     day, month, year = self


Test patch:
diff --git a/dateutil/test/test_parser.py b/dateutil/test/test_parser.py
--- a/dateutil/test/test_parser.py
+++ b/dateutil/test/test_parser.py
@@ -777,3 +777,40 @@ def testParseWithNulls(self):
         self.assertEqual(parse(pstring),
                          datetime(1924, 8, 29))
 
+    def testNoYearFirstNoDayFirst(self):
+        dtstr = '090107'
+
+        # Should be MMDDYY
+        self.assertEqual(parse(dtstr),
+                         datetime(2007, 9, 1))
+
+        self.assertEqual(parse(dtstr, yearfirst=False, dayfirst=False),
+                         datetime(2007, 9, 1))
+
+    def testYearFirst(self):
+        dtstr = '090107'
+
+        # Should be MMDDYY
+        self.assertEqual(parse(dtstr, yearfirst=True),
+                         datetime(2009, 1, 7))
+
+        self.assertEqual(parse(dtstr, yearfirst=True, dayfirst=False),
+                         datetime(2009, 1, 7))
+
+    def testDayFirst(self):
+        dtstr = '090107'
+
+        # Should be DDMMYY
+        self.assertEqual(parse(dtstr, dayfirst=True),
+                         datetime(2007, 1, 9))
+
+        self.assertEqual(parse(dtstr, yearfirst=False, dayfirst=True),
+                         datetime(2007, 1, 9))
+
+    def testDayFirstYearFirst(self):
+        dtstr = '090107'
+        # Should be YYDDMM
+        self.assertEqual(parse(dtstr, yearfirst=True, dayfirst=True),
+                         datetime(2009, 7, 1))
+
+