<p>Given a <code>date</code> string in the form&nbsp;<code>Day Month Year</code>, where:</p>

<ul>
	<li><code>Day</code>&nbsp;is in the set <code>{&quot;1st&quot;, &quot;2nd&quot;, &quot;3rd&quot;, &quot;4th&quot;, ..., &quot;30th&quot;, &quot;31st&quot;}</code>.</li>
	<li><code>Month</code>&nbsp;is in the set <code>{&quot;Jan&quot;, &quot;Feb&quot;, &quot;Mar&quot;, &quot;Apr&quot;, &quot;May&quot;, &quot;Jun&quot;, &quot;Jul&quot;, &quot;Aug&quot;, &quot;Sep&quot;, &quot;Oct&quot;, &quot;Nov&quot;, &quot;Dec&quot;}</code>.</li>
	<li><code>Year</code>&nbsp;is in the range <code>[1900, 2100]</code>.</li>
</ul>

<p>Convert the date string to the format <code>YYYY-MM-DD</code>, where:</p>

<ul>
	<li><code>YYYY</code> denotes the 4 digit year.</li>
	<li><code>MM</code> denotes the 2 digit month.</li>
	<li><code>DD</code> denotes the 2 digit day.</li>
</ul>

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

<pre>
<strong>Input:</strong> date = &quot;20th Oct 2052&quot;
<strong>Output:</strong> &quot;2052-10-20&quot;
</pre>

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

<pre>
<strong>Input:</strong> date = &quot;6th Jun 1933&quot;
<strong>Output:</strong> &quot;1933-06-06&quot;
</pre>

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

<pre>
<strong>Input:</strong> date = &quot;26th May 1960&quot;
<strong>Output:</strong> &quot;1960-05-26&quot;
</pre>

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

<ul>
	<li>The given dates are guaranteed to be valid, so no error handling is necessary.</li>
</ul>

class Solution {
public:
    string reformatDate(string date) {

        string ans;
        ans.push_back(date[date.length()-4]);
        ans.push_back(date[date.length()-3]);
        ans.push_back(date[date.length()-2]);
        ans.push_back(date[date.length()-1]);

        ans.push_back('-');

        string month;
        month.push_back(date[date.length()-8]);
        month.push_back(date[date.length()-7]);
        month.push_back(date[date.length()-6]);
        //+date[date.length()-7]+date[date.length()-6];
        string ch;
        if(month=="Jan")
           ch="01";
        else if(month=="Feb")
           ch="02";
        else if(month=="Mar")
           ch="03";
        else if(month=="Apr")
           ch="04";
        else if(month=="May")
           ch="05";
        else if(month=="Jun")
           ch="06";
        else if(month=="Jul")
           ch="07";
        else if(month=="Aug")
           ch="08";
        else if(month=="Sep")
           ch="09";
        else if(month=="Oct")
           ch="10";
        else if(month=="Nov")
           ch="11";
        else if(month=="Dec")
           ch="12";
        
        ans=ans+ch;
        string pre="0";

        ans.push_back('-');
        
        
        if(date[1]>='0'&&date[1]<='9')
          {
           

             ans.push_back(date[0]);
            ans.push_back(date[1]);
          }
        else
          {
            

            ans.push_back('0');
            ans.push_back(date[0]);

          }


        return ans;




        
    }
};
7600