| 93 | |
| 94 | |
| 95 | DWORD YYYYMMDDToSystemTime2(LPTSTR aYYYYMMDD, SYSTEMTIME *aSystemTime) |
| 96 | // Calls YYYYMMDDToSystemTime() to fill up to two elements of the aSystemTime array. |
| 97 | // Returns 0 if the parameter is empty or invalid, otherwise a GDTR bitwise combination |
| 98 | // to indicate which of the two elements, or both, are present. |
| 99 | // Caller must ensure that aYYYYMMDD is a modifiable string since it's temporarily altered and restored here. |
| 100 | { |
| 101 | DWORD gdtr = 0; |
| 102 | if (!*aYYYYMMDD) |
| 103 | return gdtr; |
| 104 | if (*aYYYYMMDD != '-') // Since first char isn't a dash, there is a minimum present. |
| 105 | { |
| 106 | LPTSTR cp; |
| 107 | if (cp = _tcschr(aYYYYMMDD + 1, '-')) |
| 108 | *cp = '\0'; // Temporarily terminate in case only the leading part of the YYYYMMDD format is present. Otherwise, the dash and other chars would be considered invalid fields. |
| 109 | if (YYYYMMDDToSystemTime(aYYYYMMDD, aSystemTime[0], true)) // Date string is valid. |
| 110 | gdtr |= GDTR_MIN; // Indicate that minimum is present. |
| 111 | if (cp) |
| 112 | { |
| 113 | *cp = '-'; // Undo the temp. termination. |
| 114 | aYYYYMMDD = cp + 1; // Set it to the maximum's position for use below. |
| 115 | } |
| 116 | else // No dash, so there is no maximum. Indicate this by making aYYYYMMDD empty. |
| 117 | aYYYYMMDD = _T(""); |
| 118 | } |
| 119 | else // *aYYYYMMDD=='-', so only the maximum is present; thus there will be no minimum. |
| 120 | ++aYYYYMMDD; // Skip over the dash to set it to the maximum's position. |
| 121 | if (*aYYYYMMDD) // There is a maximum. |
| 122 | { |
| 123 | if (YYYYMMDDToSystemTime(aYYYYMMDD, aSystemTime[1], true)) // Date string is valid. |
| 124 | gdtr |= GDTR_MAX; // Indicate that maximum is present. |
| 125 | else |
| 126 | gdtr = 0; // Indicate that the value is invalid. |
| 127 | } |
| 128 | return gdtr; |
| 129 | } |
| 130 | |
| 131 | |
| 132 |
no test coverage detected