mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-12 00:14:25 +00:00
Detect 'Z' literal correctly; add test case
This commit is contained in:
parent
908dfc0b3b
commit
6c20aea7c5
2 changed files with 13 additions and 6 deletions
|
@ -1037,12 +1037,13 @@ static UDate tryTimeZonePatterns(const UnicodeString& sourceStr, UErrorCode& err
|
|||
if (U_FAILURE(errorCode)) {
|
||||
return 0;
|
||||
}
|
||||
// 'zzzz' to handle the case where the timezone offset follows the ISO 8601 datetime
|
||||
if (sourceStr.length() > 25) {
|
||||
return tryPattern("YYYY-MM-dd'T'HH:mm:sszzzz", sourceStr, errorCode);
|
||||
int32_t len = sourceStr.length();
|
||||
if (len > 0 && sourceStr[len] == 'Z') {
|
||||
// 'Z' to handle the literal 'Z'
|
||||
return tryPattern("YYYY-MM-dd'T'HH:mm:ssZ", sourceStr, errorCode);
|
||||
}
|
||||
// 'Z' to handle the literal 'Z'
|
||||
return tryPattern("YYYY-MM-dd'T'HH:mm:ssZ", sourceStr, errorCode);
|
||||
// 'zzzz' to handle the case where the timezone offset follows the ISO 8601 datetime
|
||||
return tryPattern("YYYY-MM-dd'T'HH:mm:sszzzz", sourceStr, errorCode);
|
||||
}
|
||||
|
||||
static TimeZone* createTimeZone(const DateInfo& dateInfo, UErrorCode& errorCode) {
|
||||
|
|
|
@ -114,7 +114,13 @@
|
|||
"params": [{ "name": "val", "value": {"decimal": "1234567890123456789.987654321"} }]
|
||||
}
|
||||
],
|
||||
"datetime_extra": [
|
||||
"datetime_extra": [
|
||||
{
|
||||
"srcs": [".local $d = {|2024-07-02T19:23:45Z| :datetime timeStyle=long}\n",
|
||||
"{{Expires at {$d} or {$d :datetime timeStyle=full}}}"],
|
||||
"exp": "Expires at 7:23:45\u202FPM GMT or 7:23:45\u202FPM Greenwich Mean Time",
|
||||
"comment": "This checks that the return value of :datetime preserves the time zone offset if specified"
|
||||
},
|
||||
{
|
||||
"srcs": [".local $d = {|2024-07-02T19:23:45+03:30| :datetime timeStyle=long}\n",
|
||||
"{{Expires at {$d} or {$d :datetime timeStyle=full}}}"],
|
||||
|
|
Loading…
Add table
Reference in a new issue