mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-15 11:30:59 +01:00
SyntaxException for DateTimeParser::parse not working #569
This commit is contained in:
parent
d49ffcfb13
commit
e2836431ae
@ -280,6 +280,21 @@ private:
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
|
||||
|
||||
inline double DateTime::toJulianDay(Timestamp::UtcTimeVal utcTime)
|
||||
{
|
||||
double utcDays = double(utcTime)/864000000000.0;
|
||||
return utcDays + 2299160.5; // first day of Gregorian reform (Oct 15 1582)
|
||||
}
|
||||
|
||||
|
||||
inline Timestamp::UtcTimeVal DateTime::toUtcTime(double julianDay)
|
||||
{
|
||||
return Timestamp::UtcTimeVal((julianDay - 2299160.5)*864000000000.0);
|
||||
}
|
||||
|
||||
|
||||
inline Timestamp DateTime::timestamp() const
|
||||
{
|
||||
return Timestamp::fromUtcTime(_utcTime);
|
||||
|
@ -19,16 +19,21 @@
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include <unordered_set>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class RegularExpression;
|
||||
|
||||
|
||||
class Foundation_API DateTimeFormat
|
||||
/// Definition of date/time formats and various
|
||||
/// constants used by DateTimeFormatter and DateTimeParser.
|
||||
{
|
||||
public:
|
||||
|
||||
// predefined date formats
|
||||
static const std::string ISO8601_FORMAT;
|
||||
/// The date/time format defined in the ISO 8601 standard.
|
||||
@ -37,6 +42,8 @@ public:
|
||||
/// 2005-01-01T12:00:00+01:00
|
||||
/// 2005-01-01T11:00:00Z
|
||||
|
||||
static const std::string ISO8601_REGEX;
|
||||
|
||||
static const std::string ISO8601_FRAC_FORMAT;
|
||||
/// The date/time format defined in the ISO 8601 standard,
|
||||
/// with fractional seconds.
|
||||
@ -44,7 +51,7 @@ public:
|
||||
/// Examples:
|
||||
/// 2005-01-01T12:00:00.000000+01:00
|
||||
/// 2005-01-01T11:00:00.000000Z
|
||||
|
||||
|
||||
static const std::string RFC822_FORMAT;
|
||||
/// The date/time format defined in RFC 822 (obsoleted by RFC 1123).
|
||||
///
|
||||
@ -52,6 +59,8 @@ public:
|
||||
/// Sat, 1 Jan 05 12:00:00 +0100
|
||||
/// Sat, 1 Jan 05 11:00:00 GMT
|
||||
|
||||
static const std::string RFC822_REGEX;
|
||||
|
||||
static const std::string RFC1123_FORMAT;
|
||||
/// The date/time format defined in RFC 1123 (obsoletes RFC 822).
|
||||
///
|
||||
@ -59,6 +68,8 @@ public:
|
||||
/// Sat, 1 Jan 2005 12:00:00 +0100
|
||||
/// Sat, 1 Jan 2005 11:00:00 GMT
|
||||
|
||||
static const std::string RFC1123_REGEX;
|
||||
|
||||
static const std::string HTTP_FORMAT;
|
||||
/// The date/time format defined in the HTTP specification (RFC 2616),
|
||||
/// which is basically a variant of RFC 1036 with a zero-padded day field.
|
||||
@ -67,6 +78,8 @@ public:
|
||||
/// Sat, 01 Jan 2005 12:00:00 +0100
|
||||
/// Sat, 01 Jan 2005 11:00:00 GMT
|
||||
|
||||
static const std::string HTTP_REGEX;
|
||||
|
||||
static const std::string RFC850_FORMAT;
|
||||
/// The date/time format defined in RFC 850 (obsoleted by RFC 1036).
|
||||
///
|
||||
@ -74,6 +87,8 @@ public:
|
||||
/// Saturday, 1-Jan-05 12:00:00 +0100
|
||||
/// Saturday, 1-Jan-05 11:00:00 GMT
|
||||
|
||||
static const std::string RFC850_REGEX;
|
||||
|
||||
static const std::string RFC1036_FORMAT;
|
||||
/// The date/time format defined in RFC 1036 (obsoletes RFC 850).
|
||||
///
|
||||
@ -81,11 +96,15 @@ public:
|
||||
/// Saturday, 1 Jan 05 12:00:00 +0100
|
||||
/// Saturday, 1 Jan 05 11:00:00 GMT
|
||||
|
||||
static const std::string RFC1036_REGEX;
|
||||
|
||||
static const std::string ASCTIME_FORMAT;
|
||||
/// The date/time format produced by the ANSI C asctime() function.
|
||||
///
|
||||
/// Example:
|
||||
/// Sat Jan 1 12:00:00 2005
|
||||
/// Sat Jan 1 12:00:00 2005
|
||||
|
||||
static const std::string ASCTIME_REGEX;
|
||||
|
||||
static const std::string SORTABLE_FORMAT;
|
||||
/// A simple, sortable date/time format.
|
||||
@ -93,13 +112,28 @@ public:
|
||||
/// Example:
|
||||
/// 2005-01-01 12:00:00
|
||||
|
||||
static const std::string SORTABLE_REGEX;
|
||||
// ^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d)$
|
||||
|
||||
// names used by formatter and parser
|
||||
static const std::string WEEKDAY_NAMES[7];
|
||||
/// English names of week days (Sunday, Monday, Tuesday, ...).
|
||||
|
||||
|
||||
static const std::string MONTH_NAMES[12];
|
||||
/// English names of months (January, February, ...).
|
||||
/// English names of months (January, February, ...).
|
||||
|
||||
static bool hasFormat(const std::string& fmt);
|
||||
/// Returns true if fmt is a known standard format.
|
||||
|
||||
static bool isValid(const std::string& dateTime);
|
||||
/// Returns true if dateTime validates against at least one supported format.
|
||||
|
||||
typedef std::unordered_set<const std::string*> RegexList;
|
||||
static RegexList REGEX_LIST;
|
||||
|
||||
private:
|
||||
typedef std::unordered_set<std::string> Formatlist;
|
||||
static Formatlist FORMAT_LIST;
|
||||
};
|
||||
|
||||
|
||||
|
@ -46,13 +46,9 @@ class Foundation_API DateTimeParser
|
||||
/// two or four digits. Years 69-00 are interpreted in the 20th century
|
||||
/// (1969-2000), years 01-68 in the 21th century (2001-2068).
|
||||
///
|
||||
/// Note that in the current implementation all characters other than format specifiers in
|
||||
/// the format string are ignored/not matched against the date/time string. This may
|
||||
/// lead to non-error results even with nonsense input strings.
|
||||
/// This may change in a future version to a more strict behavior.
|
||||
/// If more strict format validation of date/time strings is required, a regular
|
||||
/// expression could be used for initial validation, before passing the string
|
||||
/// to DateTimeParser.
|
||||
/// Note that only formats defined in this class are checked for validity. This may
|
||||
/// lead to non-error results even with nonsense input strings for custom formats,
|
||||
/// which will only throw exception if format or date/time string are empty.
|
||||
{
|
||||
public:
|
||||
static void parse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential);
|
||||
@ -66,13 +62,13 @@ public:
|
||||
/// Throws a SyntaxException if the string cannot be successfully parsed.
|
||||
/// Please see DateTimeFormatter::format() for a description of the format string.
|
||||
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
||||
|
||||
|
||||
static bool tryParse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential);
|
||||
/// Parses a date and time in the given format from the given string.
|
||||
/// Returns true if the string has been successfully parsed, false otherwise.
|
||||
/// Please see DateTimeFormatter::format() for a description of the format string.
|
||||
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
||||
|
||||
|
||||
static void parse(const std::string& str, DateTime& dateTime, int& timeZoneDifferential);
|
||||
/// Parses a date and time from the given dateTime string. Before parsing, the method
|
||||
/// examines the dateTime string for a known date/time format.
|
||||
|
@ -23,19 +23,6 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
inline double DateTime::toJulianDay(Timestamp::UtcTimeVal utcTime)
|
||||
{
|
||||
double utcDays = double(utcTime)/864000000000.0;
|
||||
return utcDays + 2299160.5; // first day of Gregorian reform (Oct 15 1582)
|
||||
}
|
||||
|
||||
|
||||
inline Timestamp::UtcTimeVal DateTime::toUtcTime(double julianDay)
|
||||
{
|
||||
return Timestamp::UtcTimeVal((julianDay - 2299160.5)*864000000000.0);
|
||||
}
|
||||
|
||||
|
||||
DateTime::DateTime()
|
||||
{
|
||||
Timestamp now;
|
||||
@ -52,7 +39,7 @@ DateTime::DateTime(const Timestamp& rTimestamp):
|
||||
computeDaytime();
|
||||
}
|
||||
|
||||
|
||||
|
||||
DateTime::DateTime(int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicrosecond):
|
||||
_year(otherYear),
|
||||
_month(otherMonth),
|
||||
@ -63,13 +50,15 @@ DateTime::DateTime(int otherYear, int otherMonth, int otherDay, int otherHour, i
|
||||
_millisecond(otherMillisecond),
|
||||
_microsecond(otherMicrosecond)
|
||||
{
|
||||
if(isValid(_year, _month, _day, _hour, _minute, _second, _millisecond, _microsecond))
|
||||
if (isValid(_year, _month, _day, _hour, _minute, _second, _millisecond, _microsecond))
|
||||
{
|
||||
_utcTime = toUtcTime(toJulianDay(_year, _month, _day)) + 10*(_hour*Timespan::HOURS + _minute*Timespan::MINUTES + _second*Timespan::SECONDS + _millisecond*Timespan::MILLISECONDS + _microsecond);
|
||||
_utcTime = toUtcTime(toJulianDay(_year, _month, _day)) +
|
||||
10 * (_hour * Timespan::HOURS + _minute * Timespan::MINUTES + _second * Timespan::SECONDS +
|
||||
_millisecond * Timespan::MILLISECONDS + _microsecond);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Poco::InvalidArgumentException(Poco::format("Date time is %d-%d-%dT%d:%d:%d:%d:%d\n"
|
||||
throw Poco::InvalidArgumentException(Poco::format("Date time is %d-%d-%dT%d:%d:%d.%d.%d\n"
|
||||
"Valid values:\n"
|
||||
"0 <= year <= 9999\n"
|
||||
"1 <= month <= 12\n"
|
||||
|
@ -12,7 +12,9 @@
|
||||
//
|
||||
|
||||
|
||||
#include <Poco/Exception.h>
|
||||
#include "Poco/DateTimeFormat.h"
|
||||
#include "Poco/RegularExpression.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@ -20,13 +22,72 @@ namespace Poco {
|
||||
|
||||
const std::string DateTimeFormat::ISO8601_FORMAT("%Y-%m-%dT%H:%M:%S%z");
|
||||
const std::string DateTimeFormat::ISO8601_FRAC_FORMAT("%Y-%m-%dT%H:%M:%s%z");
|
||||
const std::string DateTimeFormat::ISO8601_REGEX("([\\+-]?\\d{4}(?!\\d{2}\\b))"
|
||||
"((-?)"
|
||||
"((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|"
|
||||
"(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))"
|
||||
"([T\\s]"
|
||||
"((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24\\:?00)([\\.,]\\d+(?!:))?)?"
|
||||
"(\\17[0-5]\\d([\\.,]\\d+)?)?([A-I]|[K-Z]|([\\+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?");
|
||||
|
||||
const std::string DateTimeFormat::RFC822_FORMAT("%w, %e %b %y %H:%M:%S %Z");
|
||||
const std::string DateTimeFormat::RFC822_REGEX("(((Mon)|(Tue)|(Wed)|(Thu)|(Fri)|(Sat)|(Sun)), *)?"
|
||||
"\\d\\d? +"
|
||||
"((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec)) +"
|
||||
"\\d\\d(\\d\\d)? +"
|
||||
"\\d\\d:\\d\\d(:\\d\\d)? +"
|
||||
"(([+\\-]?\\d\\d\\d\\d)|(UT)|(GMT)|(EST)|(EDT)|(CST)|(CDT)|(MST)|(MDT)|(PST)|(PDT)|\\w)");
|
||||
|
||||
const std::string DateTimeFormat::RFC1123_FORMAT("%w, %e %b %Y %H:%M:%S %Z");
|
||||
const std::string DateTimeFormat::RFC1123_REGEX(DateTimeFormat::RFC822_REGEX);
|
||||
|
||||
const std::string DateTimeFormat::HTTP_FORMAT("%w, %d %b %Y %H:%M:%S %Z");
|
||||
const std::string DateTimeFormat::HTTP_REGEX("(((Mon)|(Tue)|(Wed)|(Thu)|(Fri)|(Sat)|(Sun)), *)?"
|
||||
"\\d\\d? +"
|
||||
"((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec)) +"
|
||||
"\\d\\d(\\d\\d)? +\\d\\d:\\d\\d(:\\d\\d)? "
|
||||
"((UT)|(GMT)|(EST)|(EDT)|(CST)|(CDT)|(MST)|(MDT)|(PST)|(PDT)|)?+"
|
||||
"(([+\\-]?\\d\\d\\d\\d)?|(UT)|(GMT)|(EST)|(EDT)|(CST)|(CDT)|(MST)|(MDT)|(PST)|(PDT)|\\w)");
|
||||
|
||||
const std::string DateTimeFormat::RFC850_FORMAT("%W, %e-%b-%y %H:%M:%S %Z");
|
||||
const std::string DateTimeFormat::RFC850_REGEX(
|
||||
"(((Monday)|(Tuesday)|(Wednesday)|(Thursday)|(Friday)|(Saturday)|(Sunday)|"
|
||||
"(Mon)|(Tue)|(Wed)|(Thu)|(Fri)|(Sat)|(Sun)), *)?"
|
||||
"\\d\\d?-((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec))-"
|
||||
"\\d\\d(\\d\\d)? +\\d\\d:\\d\\d(:\\d\\d)? "
|
||||
"((UT)|(GMT)|(EST)|(EDT)|(CST)|(CDT)|(MST)|(MDT)|(PST)|(PDT)|)?+"
|
||||
"(([+\\-]?\\d\\d\\d\\d)?|(UT)|(GMT)|(EST)|(EDT)|(CST)|(CDT)|(MST)|(MDT)|(PST)|(PDT)|\\w)");
|
||||
|
||||
const std::string DateTimeFormat::RFC1036_FORMAT("%W, %e %b %y %H:%M:%S %Z");
|
||||
const std::string DateTimeFormat::RFC1036_REGEX(
|
||||
"(((Monday)|(Tuesday)|(Wednesday)|(Thursday)|(Friday)|(Saturday)|(Sun)), *)?"
|
||||
"\\d\\d? +"
|
||||
"((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec)) +"
|
||||
"\\d\\d(\\d\\d)? +\\d\\d:\\d\\d(:\\d\\d)? "
|
||||
"((UT)|(GMT)|(EST)|(EDT)|(CST)|(CDT)|(MST)|(MDT)|(PST)|(PDT)|)?+"
|
||||
"(([+\\-]?\\d\\d\\d\\d)?|(UT)|(GMT)|(EST)|(EDT)|(CST)|(CDT)|(MST)|(MDT)|(PST)|(PDT)|\\w)");
|
||||
|
||||
const std::string DateTimeFormat::ASCTIME_FORMAT("%w %b %f %H:%M:%S %Y");
|
||||
const std::string DateTimeFormat::ASCTIME_REGEX("((Mon)|(Tue)|(Wed)|(Thu)|(Fri)|(Sat)|(Sun)) +"
|
||||
"((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec)) +"
|
||||
"\\d\\d? +\\d\\d:\\d\\d:\\d\\d +(\\d\\d\\d\\d)");
|
||||
|
||||
const std::string DateTimeFormat::SORTABLE_FORMAT("%Y-%m-%d %H:%M:%S");
|
||||
const std::string DateTimeFormat::SORTABLE_REGEX("(\\d\\d\\d\\d-\\d\\d-\\d\\d \\d\\d:\\d\\d:\\d\\d)");
|
||||
|
||||
|
||||
DateTimeFormat::Formatlist DateTimeFormat::FORMAT_LIST(
|
||||
{
|
||||
DateTimeFormat::ISO8601_FORMAT,
|
||||
DateTimeFormat::ISO8601_FRAC_FORMAT,
|
||||
DateTimeFormat::RFC822_FORMAT,
|
||||
DateTimeFormat::RFC1123_FORMAT,
|
||||
DateTimeFormat::HTTP_FORMAT,
|
||||
DateTimeFormat::RFC850_FORMAT,
|
||||
DateTimeFormat::RFC1036_FORMAT,
|
||||
DateTimeFormat::ASCTIME_FORMAT,
|
||||
DateTimeFormat::SORTABLE_FORMAT
|
||||
});
|
||||
|
||||
|
||||
const std::string DateTimeFormat::WEEKDAY_NAMES[] =
|
||||
@ -58,4 +119,33 @@ const std::string DateTimeFormat::MONTH_NAMES[] =
|
||||
};
|
||||
|
||||
|
||||
DateTimeFormat::RegexList DateTimeFormat::REGEX_LIST =
|
||||
{
|
||||
&DateTimeFormat::ISO8601_REGEX,
|
||||
&DateTimeFormat::RFC822_REGEX,
|
||||
&DateTimeFormat::RFC1123_REGEX,
|
||||
&DateTimeFormat::HTTP_REGEX,
|
||||
&DateTimeFormat::RFC850_REGEX,
|
||||
&DateTimeFormat::RFC1036_REGEX,
|
||||
&DateTimeFormat::ASCTIME_REGEX,
|
||||
&DateTimeFormat::SORTABLE_REGEX
|
||||
};
|
||||
|
||||
|
||||
bool DateTimeFormat::hasFormat(const std::string& fmt)
|
||||
{
|
||||
return FORMAT_LIST.find(fmt) != FORMAT_LIST.end();
|
||||
}
|
||||
|
||||
|
||||
bool DateTimeFormat::isValid(const std::string& dateTime)
|
||||
{
|
||||
for (const auto& f : REGEX_LIST)
|
||||
{
|
||||
if (RegularExpression(*f).match(dateTime)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
@ -42,10 +42,13 @@ namespace Poco {
|
||||
{ int i = 0; while (i < n && it != end && Ascii::isDigit(*it)) { var = var*10 + ((*it++) - '0'); i++; } while (i++ < n) var *= 10; }
|
||||
|
||||
|
||||
void DateTimeParser::parse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential)
|
||||
void DateTimeParser::parse(const std::string& fmt,
|
||||
const std::string& str,
|
||||
DateTime& dateTime,
|
||||
int& timeZoneDifferential)
|
||||
{
|
||||
if (fmt.empty() || str.empty())
|
||||
throw SyntaxException("Empty string.");
|
||||
if (fmt.empty() || str.empty() || (DateTimeFormat::hasFormat(fmt) && !DateTimeFormat::isValid(str)))
|
||||
throw SyntaxException("Invalid DateTimeString:" + str);
|
||||
|
||||
int year = 0;
|
||||
int month = 0;
|
||||
@ -184,8 +187,11 @@ DateTime DateTimeParser::parse(const std::string& fmt, const std::string& str, i
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool DateTimeParser::tryParse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential)
|
||||
|
||||
bool DateTimeParser::tryParse(const std::string& fmt,
|
||||
const std::string& str,
|
||||
DateTime& dateTime,
|
||||
int& timeZoneDifferential)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -26,7 +26,7 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
const int RegularExpression::OVEC_SIZE = 64;
|
||||
const int RegularExpression::OVEC_SIZE = 128;
|
||||
|
||||
|
||||
RegularExpression::RegularExpression(const std::string& pattern, int options, bool study): _pcre(0), _extra(0)
|
||||
|
@ -46,6 +46,7 @@ void DateTimeParserTest::testISO8601()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12.30:00Z", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FORMAT, "2005-01-08T12:30:00+01:00", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -55,6 +56,7 @@ void DateTimeParserTest::testISO8601()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 3600);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-8T12:30:00+01:00", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FORMAT, "2005-01-08T12:30:00-01:00", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -64,6 +66,7 @@ void DateTimeParserTest::testISO8601()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == -3600);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-0812:30:00-01:00", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FORMAT, "2005-01-08T12:30:00", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -73,6 +76,7 @@ void DateTimeParserTest::testISO8601()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:0", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FORMAT, "2005-01-08", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -82,6 +86,7 @@ void DateTimeParserTest::testISO8601()
|
||||
assert (dt.minute() == 0);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-8", tzd);
|
||||
}
|
||||
|
||||
|
||||
@ -98,6 +103,7 @@ void DateTimeParserTest::testISO8601Frac()
|
||||
assert (dt.millisecond() == 0);
|
||||
assert (dt.microsecond() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-1-08T12:30:00Z", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00+01:00", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -109,6 +115,7 @@ void DateTimeParserTest::testISO8601Frac()
|
||||
assert (dt.millisecond() == 0);
|
||||
assert (dt.microsecond() == 0);
|
||||
assert (tzd == 3600);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08Z12:30:00+01:00", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00-01:00", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -120,6 +127,7 @@ void DateTimeParserTest::testISO8601Frac()
|
||||
assert (dt.millisecond() == 0);
|
||||
assert (dt.microsecond() == 0);
|
||||
assert (tzd == -3600);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00-01.00", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -131,6 +139,7 @@ void DateTimeParserTest::testISO8601Frac()
|
||||
assert (dt.millisecond() == 0);
|
||||
assert (dt.microsecond() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12;30:00", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -142,6 +151,7 @@ void DateTimeParserTest::testISO8601Frac()
|
||||
assert (dt.millisecond() == 0);
|
||||
assert (dt.microsecond() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01+08", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00.1Z", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -153,6 +163,7 @@ void DateTimeParserTest::testISO8601Frac()
|
||||
assert (dt.millisecond() == 100);
|
||||
assert (dt.microsecond() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00.1J", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00.123+01:00", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -164,6 +175,7 @@ void DateTimeParserTest::testISO8601Frac()
|
||||
assert (dt.millisecond() == 123);
|
||||
assert (dt.microsecond() == 0);
|
||||
assert (tzd == 3600);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00.123*01:00", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00.12345-01:00", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -175,6 +187,7 @@ void DateTimeParserTest::testISO8601Frac()
|
||||
assert (dt.millisecond() == 123);
|
||||
assert (dt.microsecond() == 450);
|
||||
assert (tzd == -3600);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01+08T12:30:00.12345-01:00", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2010-09-23T16:17:01.2817002+02:00", tzd);
|
||||
assert (dt.year() == 2010);
|
||||
@ -186,6 +199,7 @@ void DateTimeParserTest::testISO8601Frac()
|
||||
assert (dt.millisecond() == 281);
|
||||
assert (dt.microsecond() == 700);
|
||||
assert (tzd == 7200);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "201009-23T16:17:01.2817002+02:00", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -197,6 +211,7 @@ void DateTimeParserTest::testISO8601Frac()
|
||||
assert (dt.millisecond() == 0);
|
||||
assert (dt.microsecond() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:0", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00.123456", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -208,6 +223,7 @@ void DateTimeParserTest::testISO8601Frac()
|
||||
assert (dt.millisecond() == 123);
|
||||
assert (dt.microsecond() == 456);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "005-01-08T12:30:00.123456", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -219,6 +235,9 @@ void DateTimeParserTest::testISO8601Frac()
|
||||
assert (dt.millisecond() == 0);
|
||||
assert (dt.microsecond() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-0", tzd);
|
||||
|
||||
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "jnghjgnbcfjb", tzd);
|
||||
}
|
||||
|
||||
|
||||
@ -233,6 +252,7 @@ void DateTimeParserTest::testRFC822()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::RFC822_FORMAT, "at, 8 Jan 05 12:30:00 GMT", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC822_FORMAT, "Sat, 8 Jan 05 12:30:00 +0100", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -242,6 +262,7 @@ void DateTimeParserTest::testRFC822()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 3600);
|
||||
testBad(DateTimeFormat::RFC822_FORMAT, "Sat, x Jan 05 12:30:00 +0100", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC822_FORMAT, "Sat, 8 Jan 05 12:30:00 -0100", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -251,33 +272,37 @@ void DateTimeParserTest::testRFC822()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == -3600);
|
||||
testBad(DateTimeFormat::RFC822_FORMAT, "Sat, 8 Jan 05 12:30:00 *0100", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC822_FORMAT, "Tue, 18 Jan 05 12:30:00 CET", tzd);
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC822_FORMAT, "Tue, 18 Jan 05 12:30:00 CDT", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
assert (dt.month() == 1);
|
||||
assert (dt.day() == 18);
|
||||
assert (dt.hour() == 12);
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 3600);
|
||||
assert (tzd == -18000);
|
||||
testBad(DateTimeFormat::RFC822_FORMAT, "Tue, 18 Jan 05 12:30:00 abc", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC822_FORMAT, "Wed, 12 Sep 73 02:01:12 CEST", tzd);
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC822_FORMAT, "Wed, 12 Sep 73 02:01:12 CST", tzd);
|
||||
assert (dt.year() == 1973);
|
||||
assert (dt.month() == 9);
|
||||
assert (dt.day() == 12);
|
||||
assert (dt.hour() == 2);
|
||||
assert (dt.minute() == 1);
|
||||
assert (dt.second() == 12);
|
||||
assert (tzd == 7200);
|
||||
assert (tzd == -21600);
|
||||
testBad(DateTimeFormat::RFC822_FORMAT, "Wed, 12 Sep 73 02:01:2 CST", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC822_FORMAT, "12 Sep 73 02:01:12 CEST", tzd);
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC822_FORMAT, "12 Sep 73 02:01:12 EST", tzd);
|
||||
assert (dt.year() == 1973);
|
||||
assert (dt.month() == 9);
|
||||
assert (dt.day() == 12);
|
||||
assert (dt.hour() == 2);
|
||||
assert (dt.minute() == 1);
|
||||
assert (dt.second() == 12);
|
||||
assert (tzd == 7200);
|
||||
assert (tzd == -18000);
|
||||
testBad(DateTimeFormat::RFC822_FORMAT, "12 Sep 73 02.01:12 EST", tzd);
|
||||
}
|
||||
|
||||
|
||||
@ -292,6 +317,7 @@ void DateTimeParserTest::testRFC1123()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::RFC1123_FORMAT, "Sat, 8 Jan 2005 12:30:00 GPX", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC1123_FORMAT, "Sat, 8 Jan 2005 12:30:00 +0100", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -301,6 +327,7 @@ void DateTimeParserTest::testRFC1123()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 3600);
|
||||
testBad(DateTimeFormat::RFC1123_FORMAT, "Sat, 8 Jan 2005 xy:30:00 +0100", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC1123_FORMAT, "Sat, 8 Jan 2005 12:30:00 -0100", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -310,24 +337,37 @@ void DateTimeParserTest::testRFC1123()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == -3600);
|
||||
testBad(DateTimeFormat::RFC1123_FORMAT, "Sat, 8 Jan 205 12:30:00 -0100", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC1123_FORMAT, "Sun, 20 Jul 1969 16:17:30 EDT", tzd);
|
||||
assert (dt.year() == 1969);
|
||||
assert (dt.month() == 7);
|
||||
assert (dt.day() == 20);
|
||||
assert (dt.hour() == 16);
|
||||
assert (dt.minute() == 17);
|
||||
assert (dt.second() == 30);
|
||||
assert (tzd == -14400);
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC1123_FORMAT, "Tue, 18 Jan 2005 12:30:00 CDT", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
assert (dt.month() == 1);
|
||||
assert (dt.day() == 18);
|
||||
assert (dt.hour() == 12);
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == -18000);
|
||||
testBad(DateTimeFormat::RFC1123_FORMAT, "Hue, 18 Jan 2005 12:30:00 CDT", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC1123_FORMAT, "Sun, 20 Jul 1969 16:17:30 GMT+01:00", tzd);
|
||||
assert (dt.year() == 1969);
|
||||
assert (dt.month() == 7);
|
||||
assert (dt.day() == 20);
|
||||
assert (dt.hour() == 16);
|
||||
assert (dt.minute() == 17);
|
||||
assert (dt.second() == 30);
|
||||
assert (tzd == 3600);
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC1123_FORMAT, "Wed, 12 Sep 1973 02:01:12 CST", tzd);
|
||||
assert (dt.year() == 1973);
|
||||
assert (dt.month() == 9);
|
||||
assert (dt.day() == 12);
|
||||
assert (dt.hour() == 2);
|
||||
assert (dt.minute() == 1);
|
||||
assert (dt.second() == 12);
|
||||
assert (tzd == -21600);
|
||||
testBad(DateTimeFormat::RFC1123_FORMAT, "Wed, 12 Sp 1973 02:01:12 CST", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC1123_FORMAT, "12 Sep 1973 02:01:12 EST", tzd);
|
||||
assert (dt.year() == 1973);
|
||||
assert (dt.month() == 9);
|
||||
assert (dt.day() == 12);
|
||||
assert (dt.hour() == 2);
|
||||
assert (dt.minute() == 1);
|
||||
assert (dt.second() == 12);
|
||||
assert (tzd == -18000);
|
||||
testBad(DateTimeFormat::RFC1123_FORMAT, "12 Sep 193 02:01:12 EST", tzd);
|
||||
}
|
||||
|
||||
|
||||
@ -342,6 +382,7 @@ void DateTimeParserTest::testHTTP()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::HTTP_FORMAT, "Sat, 08 Jn 2005 12:30:00 GMT", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::HTTP_FORMAT, "Sat, 08 Jan 2005 12:30:00 +0100", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -351,6 +392,7 @@ void DateTimeParserTest::testHTTP()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 3600);
|
||||
testBad(DateTimeFormat::HTTP_FORMAT, "Sat, 08 Jan 2005 12:30:00 j0100", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::HTTP_FORMAT, "Sat, 08 Jan 2005 12:30:00 -0100", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -360,6 +402,7 @@ void DateTimeParserTest::testHTTP()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == -3600);
|
||||
testBad(DateTimeFormat::HTTP_FORMAT, "Sat 08 Jan 2005 12:30:00 -0100", tzd);
|
||||
}
|
||||
|
||||
|
||||
@ -374,6 +417,7 @@ void DateTimeParserTest::testRFC850()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::RFC850_FORMAT, "Saturday, 8-Jan 05 12:30:00 GMT", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC850_FORMAT, "Saturday, 8-Jan-05 12:30:00 +0100", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -383,6 +427,7 @@ void DateTimeParserTest::testRFC850()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 3600);
|
||||
testBad(DateTimeFormat::RFC850_FORMAT, "Saturday, 8+Jan-05 12:30:00 +0100", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC850_FORMAT, "Saturday, 8-Jan-05 12:30:00 -0100", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -392,15 +437,17 @@ void DateTimeParserTest::testRFC850()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == -3600);
|
||||
testBad(DateTimeFormat::RFC850_FORMAT, "Saturday 8-Jan-05 12:30:00 -0100", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC850_FORMAT, "Wed, 12-Sep-73 02:01:12 CEST", tzd);
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC850_FORMAT, "Wed, 12-Sep-73 02:01:12 CST", tzd);
|
||||
assert (dt.year() == 1973);
|
||||
assert (dt.month() == 9);
|
||||
assert (dt.day() == 12);
|
||||
assert (dt.hour() == 2);
|
||||
assert (dt.minute() == 1);
|
||||
assert (dt.second() == 12);
|
||||
assert (tzd == 7200);
|
||||
assert (tzd == -21600);
|
||||
testBad(DateTimeFormat::RFC850_FORMAT, "Wed, 12-pep-73 02:01:12 CST", tzd);
|
||||
}
|
||||
|
||||
|
||||
@ -415,6 +462,7 @@ void DateTimeParserTest::testRFC1036()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::RFC1036_FORMAT, "Saturday, 8 Jan 0512:30:00 GMT", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC1036_FORMAT, "Saturday, 8 Jan 05 12:30:00 +0100", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -424,6 +472,7 @@ void DateTimeParserTest::testRFC1036()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 3600);
|
||||
testBad(DateTimeFormat::RFC1036_FORMAT, "Saturday, 8 Jan 051 12:30:00 +0100", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::RFC1036_FORMAT, "Saturday, 8 Jan 05 12:30:00 -0100", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -433,6 +482,7 @@ void DateTimeParserTest::testRFC1036()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == -3600);
|
||||
testBad(DateTimeFormat::RFC1036_FORMAT, "Saturday, 8 Jan 05 12:30:00 -0100x", tzd);
|
||||
}
|
||||
|
||||
|
||||
@ -447,6 +497,7 @@ void DateTimeParserTest::testASCTIME()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::ASCTIME_FORMAT, "Bat Jan 8 12:30:00 2005", tzd);
|
||||
}
|
||||
|
||||
|
||||
@ -461,6 +512,7 @@ void DateTimeParserTest::testSORTABLE()
|
||||
assert (dt.minute() == 30);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::SORTABLE_FORMAT, "2005-01-08 12:30;00", tzd);
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::SORTABLE_FORMAT, "2005-01-08", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
@ -470,6 +522,7 @@ void DateTimeParserTest::testSORTABLE()
|
||||
assert (dt.minute() == 0);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 0);
|
||||
testBad(DateTimeFormat::SORTABLE_FORMAT, "2005+01-08", tzd);
|
||||
}
|
||||
|
||||
|
||||
@ -484,7 +537,7 @@ void DateTimeParserTest::testCustom()
|
||||
assert (dt.minute() == 0);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 0);
|
||||
|
||||
|
||||
dt = DateTimeParser::parse("%m/%d/%y", "01/18/05", tzd);
|
||||
assert (dt.year() == 2005);
|
||||
assert (dt.month() == 1);
|
||||
@ -493,7 +546,7 @@ void DateTimeParserTest::testCustom()
|
||||
assert (dt.minute() == 0);
|
||||
assert (dt.second() == 0);
|
||||
assert (tzd == 0);
|
||||
|
||||
|
||||
dt = DateTimeParser::parse("%h:%M %a", "12:30 am", tzd);
|
||||
assert (dt.hour() == 0);
|
||||
assert (dt.minute() == 30);
|
||||
@ -758,6 +811,18 @@ void DateTimeParserTest::testParseDayOfWeek()
|
||||
}
|
||||
|
||||
|
||||
void DateTimeParserTest::testBad(const std::string& fmt, const std::string& dateStr, int tzd)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime dt;
|
||||
DateTimeParser::parse(fmt, dateStr, dt, tzd);
|
||||
fail ("must fail");
|
||||
}
|
||||
catch(const Poco::Exception) { }
|
||||
}
|
||||
|
||||
|
||||
void DateTimeParserTest::setUp()
|
||||
{
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
void testBad(const std::string& fmt, const std::string& dateStr, int tzd);
|
||||
};
|
||||
|
||||
|
||||
|
@ -40,11 +40,12 @@ void RegularExpressionTest::testIndex()
|
||||
|
||||
void RegularExpressionTest::testMatch1()
|
||||
{
|
||||
RegularExpression re("[0-9]+");
|
||||
assert (re.match("123"));
|
||||
RegularExpression re("([\\+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T\\s]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24\\:?00)([\\.,]\\d+(?!:))?)?(\\17[0-5]\\d([\\.,]\\d+)?)?([zZ]|([\\+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?");//("[0-9]+");
|
||||
assert (re.match("2005-01-08T12:30:00Z"));
|
||||
/*assert (re.match("123"));
|
||||
assert (!re.match("123cd"));
|
||||
assert (!re.match("abcde"));
|
||||
assert (re.match("ab123", 2));
|
||||
assert (re.match("ab123", 2));*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,17 +55,18 @@ namespace {
|
||||
{
|
||||
}
|
||||
|
||||
NonDefaultConstructible operator=(int val)
|
||||
NonDefaultConstructible& operator=(int val)
|
||||
{
|
||||
_val = val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const NonDefaultConstructible &other) const
|
||||
bool operator==(const NonDefaultConstructible& other) const
|
||||
{
|
||||
return (_val == other._val);
|
||||
}
|
||||
|
||||
bool operator<(const NonDefaultConstructible &other) const
|
||||
bool operator<(const NonDefaultConstructible& other) const
|
||||
{
|
||||
return (_val < other._val);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user