<p>Given a string <code>date</code> representing a <a href="https://en.wikipedia.org/wiki/Gregorian_calendar" target="_blank">Gregorian calendar</a> date formatted as <code>YYYY-MM-DD</code>, return <em>the day number of the year</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> date = &quot;2019-01-09&quot;
<strong>Output:</strong> 9
<strong>Explanation:</strong> Given date is the 9th day of the year in 2019.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> date = &quot;2019-02-10&quot;
<strong>Output:</strong> 41
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>date.length == 10</code></li>
	<li><code>date[4] == date[7] == &#39;-&#39;</code>, and all other <code>date[i]</code>&#39;s are digits</li>
	<li><code>date</code> represents a calendar date between Jan 1<sup>st</sup>, 1900 and Dec 31<sup>th</sup>, 2019.</li>
</ul>

class Solution {
public:
    int dayOfYear(string date) {
        int n1=stoi(date.substr(0,4));
        bool b=false;
        if(n1%400==0 ||(n1%4==0 && n1%100!=0)) b=true;
        if(b){
            int n2=stoi(date.substr(5,2));
            int n3=stoi(date.substr(8));
            if(n2==1) return n3;
            else if(n2==2) return 31+n3;
            else if(n2==3) return 60+n3;
            else if(n2==4) return 91+n3;
            else if(n2==5) return 121+n3;
            else if(n2==6) return 152+n3;
            else if(n2==7) return 182+n3;
            else if(n2==8) return 213+n3;
            else if(n2==9) return 244+n3;
            else if(n2==10) return 274+n3;
            else if(n2==11) return 305+n3;
            else return 335+n3;
        }
        else{
            int n2=stoi(date.substr(5,2));
            int n3=stoi(date.substr(8));
            if(n2==1) return n3;
            else if(n2==2) return 31+n3;
            else if(n2==3) return 59+n3;
            else if(n2==4) return 90+n3;
            else if(n2==5) return 120+n3;
            else if(n2==6) return 151+n3;
            else if(n2==7) return 181+n3;
            else if(n2==8) return 212+n3;
            else if(n2==9) return 243+n3;
            else if(n2==10) return 273+n3;
            else if(n2==11) return 304+n3;
            else return 334+n3;
        }
        return 0;
    }
};
10600