Time Conversion

  • + 0 comments

    string timeConversion(string s) {

    int i;
    int h1 = (int)s[1] - '0';
    int h2 = (int)s[0] - '0';
    int hh = (h2 * 10 + h1 % 10);
    string t,l;
    t=s;
    
    t[9]='\0';
    t[8]='\0';
    
    if (s[8] == 'A')
    {
        if (hh == 12)
        {
            t[0]='0';
            t[1]='0';
        }
        else
        {
    
        }
    }
    

    // If time is in "PM" else { if (hh == 12) {

        }
        else
        {
            hh = hh + 12;
            l=to_string(hh);
            t[0]=l[0];
            t[1]=l[1];
        }
    }
    
    return t;
    

    }

    Why is this wrong??

    Why is this wrong??Why is this wrong??