Index: src/dateparser-inl.h |
diff --git a/src/dateparser-inl.h b/src/dateparser-inl.h |
index c1afb7d1b6e4352a3a547dc7bb9b65725b474cf6..7e5c4e355e1a9d6122241ddf7158048cea61c0cb 100644 |
--- a/src/dateparser-inl.h |
+++ b/src/dateparser-inl.h |
@@ -137,17 +137,29 @@ bool DateParser::Parse(Vector<Char> str, |
tz.SetSign(token.ascii_sign()); |
// The following number may be empty. |
int n = 0; |
+ int length = 0; |
if (scanner.Peek().IsNumber()) { |
- n = scanner.Next().number(); |
+ DateToken token = scanner.Next(); |
+ length = token.length(); |
+ n = token.number(); |
} |
has_read_number = true; |
if (scanner.Peek().IsSymbol(':')) { |
tz.SetAbsoluteHour(n); |
+ // TODO(littledan): Use minutes as part of timezone? |
tz.SetAbsoluteMinute(kNone); |
- } else { |
+ } else if (length == 2 || length == 1) { |
+ // Handle time zones like GMT-8 |
+ tz.SetAbsoluteHour(n); |
+ tz.SetAbsoluteMinute(0); |
+ } else if (length == 4 || length == 3) { |
+ // Looks like the hhmm format |
tz.SetAbsoluteHour(n / 100); |
tz.SetAbsoluteMinute(n % 100); |
+ } else { |
+ // No need to accept time zones like GMT-12345 |
+ return false; |
} |
} else if ((token.IsAsciiSign() || token.IsSymbol(')')) && |
has_read_number) { |