Exemple #1
0
        public string Convert(string cTimeFormat, NetDateTimeFormat netDateTimeFormat)
        {
            if (String.IsNullOrWhiteSpace(cTimeFormat))
            {
                return(cTimeFormat);
            }

            foreach (char c in cTimeFormat)
            {
                if (c == MarkerChar)
                {
                    if (IsMarker)
                    {
                        OpenQuotes();
                        Builder.Append(MarkerChar);
                        IsMarker = false;
                    }
                    else
                    {
                        CloseQuotes();
                        IsMarker = true;
                    }
                }
                else
                {
                    if (IsMarker)
                    {
                        Tuple <string, string> netFormat;
                        if (NetFormats.TryGetValue(c, out netFormat))
                        {
                            CloseQuotes();
                            Builder.Append(
                                netDateTimeFormat == NetDateTimeFormat.ParseFormat
                                    ? netFormat.Item1
                                    : netFormat.Item2);
                        }
                        else
                        {
                            Builder.Append(MarkerChar);
                            Builder.Append(c);
                        }

                        IsMarker = false;
                    }
                    else
                    {
                        OpenQuotes();
                        Builder.Append(c);
                    }
                }
            }

            CloseQuotes();

            return(Builder.ToString());
        }
Exemple #2
0
 public static string ConvertCTimeToNet(string ctime, NetDateTimeFormat netDateTimeFormat)
 {
     return(new CTimeToNetFormatConverter().Convert(ctime, netDateTimeFormat));
 }