Nibbler: Removed unused ::getDateISO method

This commit is contained in:
Paul Beckingham 2015-10-28 20:13:55 -04:00
parent 51afff2e6e
commit 741afd2240
3 changed files with 2 additions and 87 deletions

View file

@ -632,75 +632,6 @@ bool Nibbler::getPartialUUID (std::string& result)
return false;
}
////////////////////////////////////////////////////////////////////////////////
// 19980119T070000Z = YYYYMMDDThhmmssZ
bool Nibbler::getDateISO (time_t& t)
{
auto i = _cursor;
if (i < _length &&
_length - i >= 16)
{
if (Lexer::isDigit ((*_input)[i + 0]) &&
Lexer::isDigit ((*_input)[i + 1]) &&
Lexer::isDigit ((*_input)[i + 2]) &&
Lexer::isDigit ((*_input)[i + 3]) &&
Lexer::isDigit ((*_input)[i + 4]) &&
Lexer::isDigit ((*_input)[i + 5]) &&
Lexer::isDigit ((*_input)[i + 6]) &&
Lexer::isDigit ((*_input)[i + 7]) &&
(*_input)[i + 8] == 'T' &&
Lexer::isDigit ((*_input)[i + 9]) &&
Lexer::isDigit ((*_input)[i + 10]) &&
Lexer::isDigit ((*_input)[i + 11]) &&
Lexer::isDigit ((*_input)[i + 12]) &&
Lexer::isDigit ((*_input)[i + 13]) &&
Lexer::isDigit ((*_input)[i + 14]) &&
(*_input)[i + 15] == 'Z')
{
_cursor += 16;
int year = ((*_input)[i + 0] - '0') * 1000
+ ((*_input)[i + 1] - '0') * 100
+ ((*_input)[i + 2] - '0') * 10
+ ((*_input)[i + 3] - '0');
int month = ((*_input)[i + 4] - '0') * 10
+ ((*_input)[i + 5] - '0');
int day = ((*_input)[i + 6] - '0') * 10
+ ((*_input)[i + 7] - '0');
int hour = ((*_input)[i + 9] - '0') * 10
+ ((*_input)[i + 10] - '0');
int minute = ((*_input)[i + 11] - '0') * 10
+ ((*_input)[i + 12] - '0');
int second = ((*_input)[i + 13] - '0') * 10
+ ((*_input)[i + 14] - '0');
// Convert to epoch.
struct tm tms {};
tms.tm_isdst = -1; // Requests that mktime determine summer time effect.
tms.tm_mon = month - 1;
tms.tm_mday = day;
tms.tm_year = year - 1900;
tms.tm_hour = hour;
tms.tm_min = minute;
tms.tm_sec = second;
#ifdef HAVE_TM_GMTOFF
tms.tm_gmtoff = 0;
#endif
t = timegm (&tms);
return true;
}
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
// Parse the longest integer using the next 'limit' characters of 'result'
// following position 'i' (when strict is true, the number of digits must be