OpenHome.Git.PersonTime.Create C# (CSharp) Method

Create() static private method

static private Create ( string aValue ) : IPersonTime
aValue string
return IPersonTime
        internal static IPersonTime Create(string aValue)
        {
            int seconds;

            int endName = aValue.IndexOf('<');
            int endEmail = aValue.IndexOf('>');

            if (endName < 0 || endEmail < 0)
            {
                return (null);
            }

            string name = aValue.Substring(0, endName).Trim();
            string email = aValue.Substring(endName + 1, endEmail - endName - 1).Trim();
            string time = aValue.Substring(endEmail + 1).Trim();
            string[] parts = time.Split(new char[] { ' ' });

            if (parts.Length != 2)
            {
                return (null);
            }

            if (!int.TryParse(parts[0], out seconds))
            {
                return (null);
            }

            DateTime at = kYearDot.Add(new TimeSpan(0, 0, seconds));

            return (new PersonTime(name, email, at, parts[1]));
        }