Skip to content

Commit

Permalink
Add time zone parsing support for 'Z' (UTC indicator)
Browse files Browse the repository at this point in the history
  • Loading branch information
discnl committed Jun 22, 2017
1 parent 51cfb64 commit a3a4e7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/common/datetimefmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,14 @@ wxDateTime::ParseFormat(const wxString& date,
if ( input == end )
return false;

if ( *input == wxS('Z') )
{
// Time is in UTC.
++input;
haveTimeZone = true;
break;
}

// and then check that it's either plus or minus sign
bool minusFound;
if ( *input == wxT('-') )
Expand Down
3 changes: 3 additions & 0 deletions tests/datetime/datetimetest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,9 @@ void DateTimeTestCase::TestTimeZoneParse()
{ "13:37+0000", true },
{ "17:37+0400", true },

// Z as UTC designator.
{ "13:37Z", true },

// Some invalid ones too.
{ "00:00-1300" }, // Offset out of range.
{ "00:00+1300" }, // Offset out of range.
Expand Down

0 comments on commit a3a4e7c

Please sign in to comment.