Fix Handling time patterns with quotes (#24589)
authorTarek Mahmoud Sayed <tarekms@microsoft.com>
Thu, 16 May 2019 17:53:08 +0000 (10:53 -0700)
committerGitHub <noreply@github.com>
Thu, 16 May 2019 17:53:08 +0000 (10:53 -0700)
We encountered some cultures have a time patterns with single quotes which we should handle keeping the parts between quotes as fixed text inside the pattern and not treat it as any of the time specifiers

src/System.Private.CoreLib/shared/System/Globalization/CultureData.Unix.cs

index 6546783..56f2482 100644 (file)
@@ -264,6 +264,19 @@ namespace System.Globalization
             {
                 switch (icuFormatString[i])
                 {
+                    case '\'':
+                        result[resultPos++] = icuFormatString[i++];
+                        while (i < icuFormatString.Length)
+                        {
+                            char current = icuFormatString[i++];
+                            result[resultPos++] = current;
+                            if (current == '\'')
+                            {
+                                break;
+                            }
+                        }
+                        break;
+
                     case ':':
                     case '.':
                     case 'H':