C++校验日期串的合法性和有效性
发布时间
阅读量:
阅读量
在进行项目接口开发过程中,为确保日期字符串的合规性,编写了相关代码,目前仅满足基础应用需求。该代码依据具体业务场景添加了部分约束条件,可根据实际情况选择性移除。
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
std::string trim(const std::string& str)
{
std::string::size_type pos = str.find_first_not_of(' ');
if (pos == std::string::npos) {
return str;
}
std::string::size_type pos2 = str.find_last_not_of(' ');
if (pos2 != std::string::npos) {
return str.substr(pos, pos2 - pos + 1);
}
全部评论 (0)
还没有任何评论哟~
