Exemple #1
0
int strDate2int(const std::string &s)
{
	std::string str(s);
	if (s.length() > 10)
		str = s.substr(0,10);
	std::size_t sep ( str.find(".",0) );
	int d ( atoi(str.substr(0, sep).c_str()) );
	std::size_t sep2 ( str.find(".", sep + 1) );
	int m ( atoi(str.substr(sep + 1,sep2 - (sep + 1)).c_str()) );
	int y ( atoi(str.substr(sep2 + 1, s.length() - (sep2 + 1)).c_str()) );
	return date2int(y, m, d);
}
Exemple #2
0
int xmlDate2int(const std::string &s)
{
	if (s.length() == 10)
	{
		int d = atoi(s.substr(8,2).c_str());
		if (d < 1 || d > 31)
			WARN("xmlDate2double(): day not in [1:31].");
		int m = atoi(s.substr(5,2).c_str());
		if (m < 1 || m > 12)
			WARN("xmlDate2double(): month not in [1:12].");
		int y = atoi(s.substr(0,4).c_str());
		return date2int(y, m, d);
	}
	return 0;
}
int xmlDate2int(const std::string &s)
{
	if (s.length() == 10)
	{
		int d = atoi(s.substr(8,2).c_str());
		if (d < 1 || d > 31)
			std::cout << "Warning: xmlDate2double() -- day not in [1:31]" << std::endl;
		int m = atoi(s.substr(5,2).c_str());
		if (m < 1 || m > 12)
			std::cout << "Warning: xmlDate2double() -- month not in [1:12]" <<
			std::endl;
		int y = atoi(s.substr(0,4).c_str());
		return date2int(y, m, d);
	}
	return 0;
}