Skip to content

Instantly share code, notes, and snippets.

@juanfal
Created December 4, 2012 13:11
Show Gist options
  • Save juanfal/4203746 to your computer and use it in GitHub Desktop.
Save juanfal/4203746 to your computer and use it in GitHub Desktop.
Mes de una fecha en cadenas
// mesdeunafecha.cpp
// juanfc 2012-06-24
//
#include <iostream>
using namespace std;
string mesdeunafecha(string fecha);
int main()
{
cout << mesdeunafecha("4/diciembre/2012") << endl;
cout << mesdeunafecha("13/enero/2012") << endl;
cout << mesdeunafecha("13/Jan/2012") << endl;
return 0;
}
string mesdeunafecha(string fecha)
{
int p1 = fecha.find("/");
int p2 = fecha.find("/", p1+1);
return fecha.substr(p1+1, p2-p1-1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment