<p>Write a program to count the number of days between two dates.</p>

<p>The two dates are given as strings, their format is <code>YYYY-MM-DD</code>&nbsp;as shown in the examples.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> date1 = "2019-06-29", date2 = "2019-06-30"
<strong>Output:</strong> 1
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> date1 = "2020-01-15", date2 = "2019-12-31"
<strong>Output:</strong> 15
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li>The given dates are valid&nbsp;dates between the years <code>1971</code> and <code>2100</code>.</li>
</ul>

class Solution:
    def daysBetweenDates(self, date1: str, date2: str) -> int:
        months = {1:31, 2:28, 3: 31, 4:30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11:30, 12:31}
        YearLength = 365
        date1, date2 = min(date1, date2), max(date1, date2)
        
        def checkLeaf(year):
            if year % 4 == 0 and year != 2100:
                return 1
            return 0
                

        def convertDate(da):
            strCon = da.split("-")
            y, m, d = [int(strCon[i]) for i in range(len(strCon))]

            for i in range(1,m):
                d += months[i]
            if m > 2:
                d += checkLeaf(y)
            return (y, d)
        
      
        def yearDiff(y1, y2):
            cur = (y2 - y1) * YearLength
            for i in range(y1, y2):
                cur += checkLeaf(i)
            return cur
        
        
        
        y1, d1 = convertDate(date1)
        y2, d2 = convertDate(date2)
        return yearDiff(y1, y2) - d1 + d2
        
            
                
            
        
        
        
        
        
        
            
        
        
        
16800