summaryrefslogtreecommitdiff
path: root/xfa/fgas/crt/cfgas_formatstring.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-06-05 11:51:23 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-06-06 19:24:11 +0000
commitb3a119e72d30a60ed40f3f093745971ae5fa7dc6 (patch)
tree259f43128c220f1ed6601c3e67778e79ebaa7d8b /xfa/fgas/crt/cfgas_formatstring.cpp
parent8a5983391252d282e27cc2478798fb056c7df68a (diff)
downloadpdfium-b3a119e72d30a60ed40f3f093745971ae5fa7dc6.tar.xz
Add more CFGAS_FormatString tests.
This CL adds some more time tests for CFGAS_FormatString. Change-Id: Ida7d9e665f304b984508ff3b404e7ea9c38ef415 Reviewed-on: https://pdfium-review.googlesource.com/6270 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fgas/crt/cfgas_formatstring.cpp')
-rw-r--r--xfa/fgas/crt/cfgas_formatstring.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp
index 58e4c9562e..22e9325df2 100644
--- a/xfa/fgas/crt/cfgas_formatstring.cpp
+++ b/xfa/fgas/crt/cfgas_formatstring.cpp
@@ -448,9 +448,9 @@ bool ParseLocaleTime(const CFX_WideString& wsTime,
dwSymbol == FXBSTR_ID(0, 0, 'H', '1') ||
dwSymbol == FXBSTR_ID(0, 0, 'h', '1') ||
dwSymbol == FXBSTR_ID(0, 0, 'K', '1')) {
- if (!FXSYS_isDecimalDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc]))
return false;
- }
+
hour = str[cc++] - '0';
if (cc < len && FXSYS_isDecimalDigit(str[cc]))
hour = hour * 10 + str[cc++] - '0';
@@ -871,7 +871,7 @@ bool TimeFormat(const CFX_WideString& wsTimePattern,
}
} else if (dwSymbol == FXBSTR_ID(0, 0, 'z', '1')) {
FX_TIMEZONE tz = pLocale->GetTimeZone();
- if (tz.tzHour != 0 && tz.tzMinute != 0) {
+ if (tz.tzHour != 0 || tz.tzMinute != 0) {
wsResult += tz.tzHour < 0 ? L"-" : L"+";
CFX_WideString wsTimezone;
@@ -996,6 +996,7 @@ bool FX_TimeFromCanonical(const CFX_WideStringC& wsTime,
hour = hour * 10 + str[cc++] - '0';
}
+
if (cc < 2 || hour >= 24)
return false;
if (cc < len) {
@@ -1042,6 +1043,23 @@ bool FX_TimeFromCanonical(const CFX_WideStringC& wsTime,
}
}
+ while (cc < len) {
+ // Skip until we find a + or - for the time zone.
+ if (str[cc] != '+' && str[cc] != '-') {
+ ++cc;
+ continue;
+ }
+
+ FX_TIMEZONE tzDiff;
+ tzDiff.tzHour = 0;
+ tzDiff.tzMinute = 0;
+ if (str[cc] != 'Z')
+ cc += ParseTimeZone(str + cc, len - cc, &tzDiff);
+
+ ResolveZone(hour, minute, tzDiff, pLocale);
+ break;
+ }
+
if (cc < len) {
FX_TIMEZONE tzDiff;
tzDiff.tzHour = 0;
@@ -1992,7 +2010,8 @@ bool CFGAS_FormatString::ParseDateTime(const CFX_WideString& wsSrcDateTime,
if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty())
return false;
- CFX_WideString wsDatePattern, wsTimePattern;
+ CFX_WideString wsDatePattern;
+ CFX_WideString wsTimePattern;
IFX_Locale* pLocale = nullptr;
FX_DATETIMETYPE eCategory =
GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern);