Added support for ISO 8601 date and time format.

This commit is contained in:
Преподобный Ален
2025-12-03 22:56:39 +03:00
parent a79b4a03a6
commit e4fc22df95
2 changed files with 5 additions and 9 deletions

View File

@@ -108,15 +108,11 @@ namespace Apostol {
ch = StrDate.at(++pos);
}
if (pos == 10)
if (pos == 10 && Date.Length() == pos)
StrDate << " 00:00:00";
if (StrDate.Length() != 19 && StrDate.Length() != 23) {
return 0;
}
try {
if ((Result = StrToDateTimeDef(StrDate.c_str(), 0, "%04d-%02d-%02d %02d:%02d:%02d")) == 0)
if ((Result = StrToDateTimeDef(StrDate.c_str(), 0)) == 0)
return -1;
return 1;
@@ -130,8 +126,8 @@ namespace Apostol {
}
//--------------------------------------------------------------------------------------------------------------
CDateTime StringToDate(const CString &Value, const CString &Format) {
return StrToDateTimeDef(Value.c_str(), 0, Format.c_str());
CDateTime StringToDate(const CString &Value) {
return StrToDateTimeDef(Value.c_str(), 0);
}
//--------------------------------------------------------------------------------------------------------------

View File

@@ -43,7 +43,7 @@ namespace Apostol {
CString DoubleToBTC(const double &Value, const CString &Format = _T("%f BTC"));
//--------------------------------------------------------------------------------------------------------------
CDateTime StringToDate(const CString &Value, const CString &Format = _T("%04d-%02d-%02d %02d:%02d:%02d"));
CDateTime StringToDate(const CString &Value);
CString DateToString(CDateTime Value, const CString &Format = _T("%Y-%m-%d %H:%M:%S"));
int VerifyDate(const CString &Date, CDateTime &Result);