MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / DateToSQL

Function DateToSQL

src/database/WizIndex.cpp:2496–2556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2494}
2495
2496CString DateToSQL(const CString& strFieldName, CString strValue)
2497{
2498 if (strValue.isEmpty())
2499 return CString();
2500 //
2501 if (!strFieldName || !*strFieldName)
2502 return CString();
2503 //
2504 QChar charOpera = strValue[0];
2505 if (charOpera == '>')
2506 {
2507 strValue.remove(0, 1);
2508 //
2509 WizOleDateTime t;
2510 if (!WizDateStringToDateTimeOfBegin(strValue, t))
2511 return CString();
2512 //
2513 return WizFormatString2("%1 >= '%2'", strFieldName, ::WizDateTimeToString(t));
2514 }
2515 else if (charOpera == '<')
2516 {
2517 strValue.remove(0, 1);
2518 //
2519 WizOleDateTime t;
2520 if (!WizDateStringToDateTimeOfEnd(strValue, t))
2521 return CString();
2522 //
2523 return WizFormatString2("%1 <= '%2'", strFieldName, ::WizDateTimeToString(t));
2524 }
2525 else if (charOpera == '=')
2526 {
2527 strValue.remove(0, 1);
2528 }
2529 else
2530 {
2531 CString strLeft;
2532 CString strRight;
2533 if (::WizStringSimpleSplit(strValue, '&', strLeft, strRight))
2534 {
2535 WizOleDateTime t1;
2536 if (!WizDateStringToDateTimeOfBegin(strLeft, t1))
2537 return CString();
2538 //
2539 WizOleDateTime t2;
2540 if (!WizDateStringToDateTimeOfEnd(strRight, t2))
2541 return CString();
2542 //
2543 return WizFormatString4("(%1 >= '%2' and %3 <= '%4')", strFieldName, ::WizDateTimeToString(t1), strFieldName, ::WizDateTimeToString(t2));
2544 }
2545 }
2546 //
2547 WizOleDateTime t1;
2548 if (!WizDateStringToDateTimeOfBegin(strValue, t1))
2549 return CString();
2550 //
2551 WizOleDateTime t2;
2552 if (!WizDateStringToDateTimeOfEnd(strValue, t2))
2553 return CString();

Callers 1

searchMethod · 0.85

Calls 9

WizFormatString2Function · 0.85
WizDateTimeToStringFunction · 0.85
WizStringSimpleSplitFunction · 0.85
WizFormatString4Function · 0.85
isEmptyMethod · 0.80
CStringClass · 0.50
removeMethod · 0.45

Tested by

no test coverage detected