mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 22:47:20 +02:00
ISO8601: Removed non-extended forms
- Removed support for non-extended forms, which is approximately half of the formats. These include: YYYYMMDD YYYYWww YYYYWwwD hhmmѕsZ hhmmZ hhZ and combinations thereof. Essentially all forms that contains run-on sequences of integers, without separators. These removed forms will still be supported via rc.dateformat. - Removed unsupported forms from iso8601d.t.cpp. - Removed unsupported forms from datetime-negative.t, and corrected the tests that now succeed.
This commit is contained in:
parent
6f38d531a1
commit
4b8fdd0fbe
4 changed files with 8 additions and 396 deletions
243
src/ISO8601.cpp
243
src/ISO8601.cpp
|
@ -61,16 +61,9 @@ void ISO8601d::ambiguity (bool value)
|
|||
// | date-ext 'T' time-ext offset-ext # Specified TZ
|
||||
// | date-ext 'T' time-ext # Local
|
||||
// | date-ext # Local
|
||||
// | date 'T' time 'Z'
|
||||
// | date 'T' time offset-ext
|
||||
// | date 'T' time
|
||||
// | date
|
||||
// | time-ext 'Z'
|
||||
// | time-ext offset-ext Not needed
|
||||
// | time-ext
|
||||
// | time 'Z'
|
||||
// | time offset
|
||||
// | time
|
||||
// ;
|
||||
//
|
||||
// date-ext ::= ±YYYYY-MM-DD Νot needed
|
||||
|
@ -83,37 +76,14 @@ void ISO8601d::ambiguity (bool value)
|
|||
// | YYYY-Www
|
||||
// ;
|
||||
//
|
||||
// date ::= ±YYYYYMMDD Νot needed
|
||||
// | ±YYYYYWwwD Νot needed
|
||||
// | ±YYYYYWww Νot needed
|
||||
// | ±YYYYYDDD Νot needed
|
||||
// | ±YYYYYMM Νot needed
|
||||
// | ±YYYYY Νot needed
|
||||
// | ±YYY Νot needed
|
||||
// | YYYYMMDD Ambiguous (number)
|
||||
// | YYYYWwwD
|
||||
// | YYYYWww
|
||||
// | YYYYDDD Ambiguous (number)
|
||||
// | YYYY-MM
|
||||
// | YYYY Ambiguous (number)
|
||||
// | YY Ambiguous (number)
|
||||
// ;
|
||||
//
|
||||
// time-ext ::= hh:mm:ss[,ss]
|
||||
// | hh:mm[,mm]
|
||||
// | hh[,hh] Ambiguous (number)
|
||||
// ;
|
||||
//
|
||||
// time ::= hhmmss[,ss] Ambiguous (number)
|
||||
// | hhmm[,mm] Ambiguous (number)
|
||||
// | hh[,hh] Ambiguous (number)
|
||||
// ;
|
||||
//
|
||||
// time-utc-ext ::= hh:mm[:ss] 'Z' ;
|
||||
// time-utc ::= hh[mm[ss]] 'Z' ;
|
||||
//
|
||||
// offset-ext ::= ±hh[:mm] ;
|
||||
// offset ::= ±hh[mm] ;
|
||||
//
|
||||
// Not yet supported:
|
||||
//
|
||||
|
@ -136,12 +106,7 @@ bool ISO8601d::parse (const std::string& input, std::string::size_type& start)
|
|||
parse_date_ext (n) ||
|
||||
parse_time_utc_ext (n) ||
|
||||
parse_time_off_ext (n) ||
|
||||
parse_date_time (n) ||
|
||||
parse_date (n, _ambiguity) ||
|
||||
parse_time_utc (n) ||
|
||||
parse_time_off (n) ||
|
||||
parse_time_ext (n) || // Time last, as it is the most permissive.
|
||||
parse_time (n, _ambiguity))
|
||||
parse_time_ext (n)) // Time last, as it is the most permissive.
|
||||
{
|
||||
// Check the values and determine time_t.
|
||||
if (validate ())
|
||||
|
@ -214,47 +179,6 @@ bool ISO8601d::parse_date_time_ext (Nibbler& n)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// date 'T' time 'Z'
|
||||
// date 'T' time offset
|
||||
// date 'T' time
|
||||
bool ISO8601d::parse_date_time (Nibbler& n)
|
||||
{
|
||||
Nibbler backup (n);
|
||||
if (parse_date (n, true))
|
||||
{
|
||||
if (n.skip ('T') &&
|
||||
parse_time (n, true))
|
||||
{
|
||||
if (n.skip ('Z'))
|
||||
{
|
||||
_utc = true;
|
||||
if (!Lexer::isDigit (n.next ()))
|
||||
return true;
|
||||
}
|
||||
else if (parse_off (n))
|
||||
{
|
||||
if (!Lexer::isDigit (n.next ()))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Lexer::isDigit (n.next ()))
|
||||
return true;
|
||||
}
|
||||
|
||||
// Restore date
|
||||
_year = 0;
|
||||
_month = 0;
|
||||
_week = 0;
|
||||
_weekday = 0;
|
||||
_julian = 0;
|
||||
_day = 0;
|
||||
}
|
||||
|
||||
n = backup;
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// YYYY-MM-DD
|
||||
// YYYY-DDD
|
||||
|
@ -303,64 +227,6 @@ bool ISO8601d::parse_date_ext (Nibbler& n)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// YYYYMMDD Ambiguous (number)
|
||||
// YYYYWwwD
|
||||
// YYYYWww
|
||||
// YYYYDDD Ambiguous (number)
|
||||
// YYYY-MM
|
||||
bool ISO8601d::parse_date (Nibbler& n, bool ambiguous)
|
||||
{
|
||||
Nibbler backup (n);
|
||||
int year;
|
||||
if (n.getDigit4 (year))
|
||||
{
|
||||
int month;
|
||||
if (n.skip ('W'))
|
||||
{
|
||||
int week;
|
||||
if (n.getDigit2 (week))
|
||||
{
|
||||
_week = week;
|
||||
|
||||
int day;
|
||||
if (n.getDigit (day))
|
||||
_weekday = day;
|
||||
|
||||
_year = year;
|
||||
if (!Lexer::isDigit (n.next ()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (n.skip ('-'))
|
||||
{
|
||||
if (n.getDigit2 (_month))
|
||||
{
|
||||
_year = year;
|
||||
if (!Lexer::isDigit (n.next ()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (n.getDigit4 (month))
|
||||
{
|
||||
_year = year;
|
||||
_month = month / 100;
|
||||
_day = month % 100;
|
||||
if (!Lexer::isDigit (n.next ()))
|
||||
return true;
|
||||
}
|
||||
else if (ambiguous && n.getDigit3 (_julian))
|
||||
{
|
||||
_year = year;
|
||||
if (!Lexer::isDigit (n.next ()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
n = backup;
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ±hh[:mm]
|
||||
bool ISO8601d::parse_off_ext (Nibbler& n)
|
||||
|
@ -394,37 +260,7 @@ bool ISO8601d::parse_off_ext (Nibbler& n)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ±hh[mm]
|
||||
bool ISO8601d::parse_off (Nibbler& n)
|
||||
{
|
||||
Nibbler backup (n);
|
||||
std::string sign;
|
||||
if (n.getN (1, sign))
|
||||
{
|
||||
if (sign == "+" || sign == "-")
|
||||
{
|
||||
int offset;
|
||||
int hh;
|
||||
if (n.getDigit2 (hh))
|
||||
{
|
||||
offset = hh * 3600;
|
||||
int mm;
|
||||
if (n.getDigit2 (mm))
|
||||
offset += mm * 60;
|
||||
|
||||
_offset = (sign == "-") ? -offset : offset;
|
||||
if (!Lexer::isDigit (n.next ()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
n = backup;
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// hh[:mm[:ss]]
|
||||
// hh:mm[:ss]
|
||||
bool ISO8601d::parse_time_ext (Nibbler& n)
|
||||
{
|
||||
Nibbler backup (n);
|
||||
|
@ -433,20 +269,15 @@ bool ISO8601d::parse_time_ext (Nibbler& n)
|
|||
int mm;
|
||||
int ss;
|
||||
if (n.getDigit2 (hh) &&
|
||||
!n.getDigit (mm))
|
||||
n.skip (':') &&
|
||||
n.getDigit2 (mm))
|
||||
{
|
||||
seconds = hh * 3600;
|
||||
|
||||
if (n.skip (':') &&
|
||||
n.getDigit2 (mm) &&
|
||||
!n.getDigit (ss))
|
||||
{
|
||||
seconds += mm * 60;
|
||||
seconds = (hh * 3600) + (mm * 60);
|
||||
|
||||
if (n.skip (':') &&
|
||||
n.getDigit2 (ss))
|
||||
{
|
||||
seconds += ss;
|
||||
|
||||
_seconds = seconds;
|
||||
return true;
|
||||
}
|
||||
|
@ -463,35 +294,6 @@ bool ISO8601d::parse_time_ext (Nibbler& n)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// hhmm[ss]
|
||||
bool ISO8601d::parse_time (Nibbler& n, bool ambiguous)
|
||||
{
|
||||
if (!ambiguous)
|
||||
return false;
|
||||
|
||||
Nibbler backup (n);
|
||||
int seconds = 0;
|
||||
int hh;
|
||||
int mm;
|
||||
if (n.getDigit2 (hh) &&
|
||||
n.getDigit2 (mm))
|
||||
{
|
||||
seconds = hh * 3600 + mm * 60;
|
||||
|
||||
int ss;
|
||||
if (n.getDigit2 (ss))
|
||||
seconds += ss;
|
||||
|
||||
_seconds = seconds;
|
||||
if (!Lexer::isDigit (n.next ()))
|
||||
return true;
|
||||
}
|
||||
|
||||
n = backup;
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// time-ext 'Z'
|
||||
bool ISO8601d::parse_time_utc_ext (Nibbler& n)
|
||||
|
@ -509,23 +311,6 @@ bool ISO8601d::parse_time_utc_ext (Nibbler& n)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// time 'Z'
|
||||
bool ISO8601d::parse_time_utc (Nibbler& n)
|
||||
{
|
||||
n.save ();
|
||||
if (parse_time (n, true) &&
|
||||
n.skip ('Z'))
|
||||
{
|
||||
_utc = true;
|
||||
if (!Lexer::isDigit (n.next ()))
|
||||
return true;
|
||||
}
|
||||
|
||||
n.restore ();
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// time-ext offset-ext
|
||||
bool ISO8601d::parse_time_off_ext (Nibbler& n)
|
||||
|
@ -542,22 +327,6 @@ bool ISO8601d::parse_time_off_ext (Nibbler& n)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// time offset
|
||||
bool ISO8601d::parse_time_off (Nibbler& n)
|
||||
{
|
||||
Nibbler backup (n);
|
||||
if (parse_time (n, true) &&
|
||||
parse_off (n))
|
||||
{
|
||||
if (!Lexer::isDigit (n.next ()))
|
||||
return true;
|
||||
}
|
||||
|
||||
n = backup;
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Using Zeller's Congruence.
|
||||
int ISO8601d::dayOfWeek (int year, int month, int day)
|
||||
|
|
|
@ -45,17 +45,11 @@ public:
|
|||
|
||||
private:
|
||||
bool parse_date_time_ext (Nibbler&);
|
||||
bool parse_date_time (Nibbler&);
|
||||
bool parse_date_ext (Nibbler&);
|
||||
bool parse_date (Nibbler&, bool);
|
||||
bool parse_off_ext (Nibbler&);
|
||||
bool parse_off (Nibbler&);
|
||||
bool parse_time_ext (Nibbler&);
|
||||
bool parse_time (Nibbler&, bool);
|
||||
bool parse_time_utc_ext (Nibbler&);
|
||||
bool parse_time_utc (Nibbler&);
|
||||
bool parse_time_off_ext (Nibbler&);
|
||||
bool parse_time_off (Nibbler&);
|
||||
int dayOfWeek (int, int, int);
|
||||
bool validate ();
|
||||
void resolve ();
|
||||
|
|
|
@ -103,38 +103,6 @@ class TestIncorrectDate(BaseDateTimeNegativeTest):
|
|||
def test_set_incorrect_datetime_day_two_hundred_in_YYYY_WwwD(self):
|
||||
self.assertInvalidDatetimeFormat('2014-W24200')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_week_with_the_number_zero_in_YYYYWww(self):
|
||||
self.assertInvalidDatetimeFormat('2014W00')
|
||||
|
||||
def test_set_incorrect_datetime_overflow_in_week_in_YYYYWww(self):
|
||||
self.assertInvalidDatetimeFormat('2014W54')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_week_zero_in_YYYYWwwD(self):
|
||||
self.assertInvalidDatetimeFormat('2014W001')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_fifth_day_of_week_zero_in_YYYYWwwD(self):
|
||||
self.assertInvalidDatetimeFormat('2014W005')
|
||||
|
||||
def test_set_incorrect_datetime_overflow_week_in_YYYYWwwD(self):
|
||||
self.assertInvalidDatetimeFormat('2014W541')
|
||||
|
||||
def test_set_incorrect_datetime_huge_overflow_week_in_YYYYWwwD(self):
|
||||
self.assertInvalidDatetimeFormat('2014W991')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_day_zero_in_YYYYWwwD(self):
|
||||
self.assertInvalidDatetimeFormat('2014W240')
|
||||
|
||||
def test_set_incorrect_datetime_day_eight_in_YYYYWwwD(self):
|
||||
self.assertInvalidDatetimeFormat('2014W248')
|
||||
|
||||
def test_set_incorrect_datetime_day_two_hundred_in_YYYYWwwD(self):
|
||||
self.assertInvalidDatetimeFormat('2014W24200')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_month_zero_in_YYYY_MM(self):
|
||||
self.assertInvalidDatetimeFormat('2014-00')
|
||||
|
||||
|
@ -211,18 +179,15 @@ class TestIncorrectTime(BaseDateTimeNegativeTest):
|
|||
def test_set_incorrect_datetime_negative_minutes_in_hh_mmZ(self):
|
||||
self.assertInvalidDatetimeFormat('12:-12Z')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_hour_overflow_in_hh_mm_plus_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('24:00+01:00')
|
||||
|
||||
def test_set_incorrect_datetime_huge_hour_overflow_in_hh_mm_plus_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('99:00+01:00')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_minute_overflow_in_hh_mm_plus_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:60+01:00')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_huge_minute_overflow_in_hh_mm_plus_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:99+01:00')
|
||||
|
||||
|
@ -241,18 +206,15 @@ class TestIncorrectTime(BaseDateTimeNegativeTest):
|
|||
def test_set_incorrect_datetime_negative_minutes_in_hh_mm_plus_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:-12+01:00')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_hour_overflow_in_hh_mm_minus_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('24:00-01:00')
|
||||
|
||||
def test_set_incorrect_datetime_huge_hour_overflow_in_hh_mm_minus_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('99:00-01:00')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_minute_overflow_in_hh_mm_minus_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:60-01:00')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_huge_minute_overflow_in_hh_mm_minus_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:99-01:00')
|
||||
|
||||
|
@ -312,7 +274,6 @@ class TestIncorrectTime(BaseDateTimeNegativeTest):
|
|||
def test_set_incorrect_datetime_negative_minutes_in_hh_mm_ss(self):
|
||||
self.assertInvalidDatetimeFormat('12:-12:12')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_negative_seconds_in_hh_mm_ss(self):
|
||||
self.assertInvalidDatetimeFormat('12:12:-12')
|
||||
|
||||
|
@ -445,7 +406,6 @@ class TestIncorrectTime(BaseDateTimeNegativeTest):
|
|||
def test_set_incorrect_datetime_negative_minutes_in_hh_mm_ss_minus_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:-12:12-01:00')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_negative_seconds_in_hh_mm_ss_minus_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:12:-12-01:00')
|
||||
|
||||
|
@ -505,22 +465,18 @@ class TestIncorrectTime(BaseDateTimeNegativeTest):
|
|||
def test_set_incorrect_datetime_invalid_negative_offset_length_in_hh_mm_ss(self):
|
||||
self.assertInvalidDatetimeFormat('12:12:12-3:2')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_invalid_hour_positive_offset_in_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:12+13:00')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_invalid_medium_hour_positive_offset_in_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:12+24:00')
|
||||
|
||||
def test_set_incorrect_datetime_invalid_huge_hour_positive_offset_in_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:12+99:00')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_invalid_minute_positive_offset_in_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:12+03:60')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_invalid_huge_minute_positive_offset_in_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:12+03:99')
|
||||
|
||||
|
@ -533,22 +489,18 @@ class TestIncorrectTime(BaseDateTimeNegativeTest):
|
|||
def test_set_incorrect_datetime_invalid_positive_offset_length_in_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:12+3:2')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_invalid_hour_negative_offset_in_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:12-13:00')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_invalid_medium_hour_negative_offset_in_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:12-24:00')
|
||||
|
||||
def test_set_incorrect_datetime_invalid_huge_hour_negative_offset_in_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:12-99:00')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_invalid_minute_negative_offset_in_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:12-03:60')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_set_incorrect_datetime_invalid_huge_minute_negative_offset_in_hh_mm(self):
|
||||
self.assertInvalidDatetimeFormat('12:12-03:99')
|
||||
|
||||
|
|
|
@ -33,9 +33,6 @@
|
|||
|
||||
Context context;
|
||||
|
||||
#define AMBIGUOUS // Include ambiguous forms
|
||||
#undef AMBIGUOUS // Exclude ambiguous forms
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void testParse (
|
||||
UnitTest& t,
|
||||
|
@ -74,11 +71,7 @@ void testParse (
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (1214
|
||||
#ifdef AMBIGUOUS
|
||||
+ 48
|
||||
#endif
|
||||
);
|
||||
UnitTest t (734);
|
||||
|
||||
ISO8601d iso;
|
||||
std::string::size_type start = 0;
|
||||
|
@ -139,7 +132,6 @@ int main (int argc, char** argv)
|
|||
|
||||
int hms = (12 * 3600) + (34 * 60) + 56; // The time 12:34:56 in seconds.
|
||||
int hm = (12 * 3600) + (34 * 60); // The time 12:34:00 in seconds.
|
||||
int h = (12 * 3600); // The time 12:00:00 in seconds.
|
||||
int z = 3600; // TZ offset.
|
||||
|
||||
int ld = local_s > hms ? 86400 : 0; // Local extra day if now > hms.
|
||||
|
@ -155,31 +147,12 @@ int main (int argc, char** argv)
|
|||
// input i Year Mo Wk WD Jul Da Secs TZ UTC time_t
|
||||
testParse (t, "12:34:56Z", 9, 0, 0, 0, 0, 0, 0, hms, 0, true, utc+hms+ud );
|
||||
testParse (t, "12:34Z", 6, 0, 0, 0, 0, 0, 0, hm, 0, true, utc+hm+ud );
|
||||
testParse (t, "12Z", 3, 0, 0, 0, 0, 0, 0, h, 0, true, utc+h+ud );
|
||||
testParse (t, "12:34:56+01:00", 14, 0, 0, 0, 0, 0, 0, hms, 3600, false, utc+hms-z+ud );
|
||||
testParse (t, "12:34:56+01", 11, 0, 0, 0, 0, 0, 0, hms, 3600, false, utc+hms-z+ud );
|
||||
testParse (t, "12:34+01:00", 11, 0, 0, 0, 0, 0, 0, hm, 3600, false, utc+hm-z+ud );
|
||||
testParse (t, "12:34+01", 8, 0, 0, 0, 0, 0, 0, hm, 3600, false, utc+hm-z+ud );
|
||||
// testParse (t, "12+01:00", 8, 0, 0, 0, 0, 0, 0, h, 3600, false, utc+h-z+ud );
|
||||
// testParse (t, "12+01", 5, 0, 0, 0, 0, 0, 0, h, 3600, false, utc+h-z+ud );
|
||||
testParse (t, "12:34:56", 8, 0, 0, 0, 0, 0, 0, hms, 0, false, local+hms+ld );
|
||||
testParse (t, "12:34", 5, 0, 0, 0, 0, 0, 0, hm, 0, false, local+hm+ld );
|
||||
#ifdef AMBIGUOUS
|
||||
testParse (t, "12", 2, 0, 0, 0, 0, 0, 0, h, 0, false, local+h+ld );
|
||||
#endif
|
||||
|
||||
// time
|
||||
// input i Year Mo Wk WD Jul Da Secs TZ UTC time_t
|
||||
testParse (t, "123456Z", 7, 0, 0, 0, 0, 0, 0, hms, 0, true, utc+hms+ud );
|
||||
testParse (t, "1234Z", 5, 0, 0, 0, 0, 0, 0, hm, 0, true, utc+hm+ud );
|
||||
testParse (t, "123456+0100", 11, 0, 0, 0, 0, 0, 0, hms, 3600, false, utc+hms-z+ud );
|
||||
testParse (t, "123456+01", 9, 0, 0, 0, 0, 0, 0, hms, 3600, false, utc+hms-z+ud );
|
||||
testParse (t, "1234+0100", 9, 0, 0, 0, 0, 0, 0, hm, 3600, false, utc+hm-z+ud );
|
||||
testParse (t, "1234+01", 7, 0, 0, 0, 0, 0, 0, hm, 3600, false, utc+hm-z+ud );
|
||||
// testParse (t, "12+0100", 7, 0, 0, 0, 0, 0, 0, h, 3600, false, utc+h-z+ud );
|
||||
#ifdef AMBIGUOUS
|
||||
testParse (t, "123456", 6, 0, 0, 0, 0, 0, 0, hms, 0, false, local+hms+ld );
|
||||
#endif
|
||||
|
||||
// datetime-ext
|
||||
// input i Year Mo Wk WD Jul Da Secs TZ UTC time_t
|
||||
|
@ -239,82 +212,6 @@ int main (int argc, char** argv)
|
|||
testParse (t, "2013-W49T12:34-01:00", 20, 2013, 0, 49, 0, 0, 0, hm, -3600, false, utc1+hm+z );
|
||||
testParse (t, "2013-W49T12:34-01", 17, 2013, 0, 49, 0, 0, 0, hm, -3600, false, utc1+hm+z );
|
||||
|
||||
// datetime
|
||||
#ifdef AMBIGUOUS
|
||||
testParse (t, "20131206", 8, 2013, 12, 0, 0, 0, 6, 0, 0, false, local6 );
|
||||
#endif
|
||||
testParse (t, "2013W495", 8, 2013, 0, 49, 5, 0, 0, 0, 0, false, local6 );
|
||||
testParse (t, "2013W49", 7, 2013, 0, 49, 0, 0, 0, 0, 0, false, local1 );
|
||||
#ifdef AMBIGUOUS
|
||||
testParse (t, "2013340", 7, 2013, 0, 0, 0, 340, 0, 0, 0, false, local6 );
|
||||
#endif
|
||||
testParse (t, "2013-12", 7, 2013, 12, 0, 0, 0, 0, 0, 0, false, local1 );
|
||||
|
||||
testParse (t, "20131206T123456", 15, 2013, 12, 0, 0, 0, 6, hms, 0, false, local6+hms);
|
||||
// testParse (t, "20131206T12", 11, 2013, 12, 0, 0, 0, 6, h, 0, false, local6+h );
|
||||
testParse (t, "2013W495T123456", 15, 2013, 0, 49, 5, 0, 0, hms, 0, false, local6+hms);
|
||||
// testParse (t, "2013W495T12", 11, 2013, 0, 49, 5, 0, 0, h, 0, false, local6+h );
|
||||
testParse (t, "2013W49T123456", 14, 2013, 0, 49, 0, 0, 0, hms, 0, false, local1+hms);
|
||||
// testParse (t, "2013W49T12", 10, 2013, 0, 49, 0, 0, 0, h, 0, false, local1+h );
|
||||
testParse (t, "2013340T123456", 14, 2013, 0, 0, 0, 340, 0, hms, 0, false, local6+hms);
|
||||
// testParse (t, "2013340T12", 10, 2013, 0, 0, 0, 340, 0, h, 0, false, local6+h );
|
||||
testParse (t, "2013-12T1234", 12, 2013, 12, 0, 0, 0, 0, hm, 0, false, local1+hm );
|
||||
// testParse (t, "2013-12T12", 10, 2013, 12, 0, 0, 0, 0, h, 0, false, local1+h );
|
||||
|
||||
testParse (t, "20131206T123456Z", 16, 2013, 12, 0, 0, 0, 6, hms, 0, true, utc6+hms );
|
||||
// testParse (t, "20131206T12Z", 12, 2013, 12, 0, 0, 0, 6, h, 0, true, utc6+h );
|
||||
testParse (t, "2013W495T123456Z", 16, 2013, 0, 49, 5, 0, 0, hms, 0, true, utc6+hms );
|
||||
// testParse (t, "2013W495T12Z", 12, 2013, 0, 49, 5, 0, 0, h, 0, true, utc6+h );
|
||||
testParse (t, "2013W49T123456Z", 15, 2013, 0, 49, 0, 0, 0, hms, 0, true, utc1+hms );
|
||||
// testParse (t, "2013W49T12Z", 11, 2013, 0, 49, 0, 0, 0, h, 0, true, utc1+h );
|
||||
testParse (t, "2013340T123456Z", 15, 2013, 0, 0, 0, 340, 0, hms, 0, true, utc6+hms );
|
||||
// testParse (t, "2013340T12Z", 11, 2013, 0, 0, 0, 340, 0, h, 0, true, utc6+h );
|
||||
testParse (t, "2013-12T123456Z", 15, 2013, 12, 0, 0, 0, 0, hms, 0, true, utc1+hms );
|
||||
// testParse (t, "2013-12T12Z", 11, 2013, 12, 0, 0, 0, 0, h, 0, true, utc1+h );
|
||||
|
||||
testParse (t, "20131206T123456+0100", 20, 2013, 12, 0, 0, 0, 6, hms, 3600, false, utc6+hms-z);
|
||||
testParse (t, "20131206T123456+01", 18, 2013, 12, 0, 0, 0, 6, hms, 3600, false, utc6+hms-z);
|
||||
testParse (t, "20131206T123456-0100", 20, 2013, 12, 0, 0, 0, 6, hms, -3600, false, utc6+hms+z);
|
||||
testParse (t, "20131206T123456-01", 18, 2013, 12, 0, 0, 0, 6, hms, -3600, false, utc6+hms+z);
|
||||
// testParse (t, "20131206T12+0100", 16, 2013, 12, 0, 0, 0, 6, h, 3600, false, utc6+h-z );
|
||||
// testParse (t, "20131206T12+01", 14, 2013, 12, 0, 0, 0, 6, h, 3600, false, utc6+h-z );
|
||||
// testParse (t, "20131206T12-0100", 16, 2013, 12, 0, 0, 0, 6, h, -3600, false, utc6+h+z );
|
||||
// testParse (t, "20131206T12-01", 14, 2013, 12, 0, 0, 0, 6, h, -3600, false, utc6+h+z );
|
||||
testParse (t, "2013W495T123456+0100", 20, 2013, 0, 49, 5, 0, 0, hms, 3600, false, utc6+hms-z);
|
||||
testParse (t, "2013W495T123456+01", 18, 2013, 0, 49, 5, 0, 0, hms, 3600, false, utc6+hms-z);
|
||||
testParse (t, "2013W495T123456-0100", 20, 2013, 0, 49, 5, 0, 0, hms, -3600, false, utc6+hms+z);
|
||||
testParse (t, "2013W495T123456-01", 18, 2013, 0, 49, 5, 0, 0, hms, -3600, false, utc6+hms+z);
|
||||
// testParse (t, "2013W495T12+0100", 16, 2013, 0, 49, 5, 0, 0, h, 3600, false, utc6+h-z );
|
||||
// testParse (t, "2013W495T12+01", 14, 2013, 0, 49, 5, 0, 0, h, 3600, false, utc6+h-z );
|
||||
// testParse (t, "2013W495T12-0100", 16, 2013, 0, 49, 5, 0, 0, h, -3600, false, utc6+h+z );
|
||||
// testParse (t, "2013W495T12-01", 14, 2013, 0, 49, 5, 0, 0, h, -3600, false, utc6+h+z );
|
||||
testParse (t, "2013W49T123456+0100", 19, 2013, 0, 49, 0, 0, 0, hms, 3600, false, utc1+hms-z);
|
||||
testParse (t, "2013W49T123456+01", 17, 2013, 0, 49, 0, 0, 0, hms, 3600, false, utc1+hms-z);
|
||||
testParse (t, "2013W49T123456-0100", 19, 2013, 0, 49, 0, 0, 0, hms, -3600, false, utc1+hms+z);
|
||||
testParse (t, "2013W49T123456-01", 17, 2013, 0, 49, 0, 0, 0, hms, -3600, false, utc1+hms+z);
|
||||
// testParse (t, "2013W49T12+0100", 15, 2013, 0, 49, 0, 0, 0, h, 3600, false, utc1+h-z );
|
||||
// testParse (t, "2013W49T12+01", 13, 2013, 0, 49, 0, 0, 0, h, 3600, false, utc1+h-z );
|
||||
// testParse (t, "2013W49T12-0100", 15, 2013, 0, 49, 0, 0, 0, h, -3600, false, utc1+h+z );
|
||||
// testParse (t, "2013W49T12-01", 13, 2013, 0, 49, 0, 0, 0, h, -3600, false, utc1+h+z );
|
||||
testParse (t, "2013340T123456+0100", 19, 2013, 0, 0, 0, 340, 0, hms, 3600, false, utc6+hms-z);
|
||||
testParse (t, "2013340T123456+01", 17, 2013, 0, 0, 0, 340, 0, hms, 3600, false, utc6+hms-z);
|
||||
testParse (t, "2013340T123456-0100", 19, 2013, 0, 0, 0, 340, 0, hms, -3600, false, utc6+hms+z);
|
||||
testParse (t, "2013340T123456-01", 17, 2013, 0, 0, 0, 340, 0, hms, -3600, false, utc6+hms+z);
|
||||
// testParse (t, "2013340T12+0100", 15, 2013, 0, 0, 0, 340, 0, h, 3600, false, utc6+h-z );
|
||||
// testParse (t, "2013340T12+01", 13, 2013, 0, 0, 0, 340, 0, h, 3600, false, utc6+h-z );
|
||||
// testParse (t, "2013340T12-0100", 15, 2013, 0, 0, 0, 340, 0, h, -3600, false, utc6+h+z );
|
||||
// testParse (t, "2013340T12-01", 13, 2013, 0, 0, 0, 340, 0, h, -3600, false, utc6+h+z );
|
||||
testParse (t, "2013-12T123456+0100", 19, 2013, 12, 0, 0, 0, 0, hms, 3600, false, utc1+hms-z);
|
||||
testParse (t, "2013-12T123456+01", 17, 2013, 12, 0, 0, 0, 0, hms, 3600, false, utc1+hms-z);
|
||||
testParse (t, "2013-12T123456-0100", 19, 2013, 12, 0, 0, 0, 0, hms, -3600, false, utc1+hms+z);
|
||||
testParse (t, "2013-12T123456-01", 17, 2013, 12, 0, 0, 0, 0, hms, -3600, false, utc1+hms+z);
|
||||
// testParse (t, "2013-12T12+0100", 15, 2013, 12, 0, 0, 0, 0, h, 3600, false, utc1+h-z );
|
||||
// testParse (t, "2013-12T12+01", 13, 2013, 12, 0, 0, 0, 0, h, 3600, false, utc1+h-z );
|
||||
// testParse (t, "2013-12T12-0100", 15, 2013, 12, 0, 0, 0, 0, h, -3600, false, utc1+h+z );
|
||||
// testParse (t, "2013-12T12-01", 13, 2013, 12, 0, 0, 0, 0, h, -3600, false, utc1+h+z );
|
||||
|
||||
// TODO Test validation of individual values.
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue