internal static bool TryParseServerString(string value, out WmDate wmDate)
        {
            if (string.IsNullOrEmpty(value))
            {
                wmDate = default(WmDate);
                return(false);
            }

            DateTime serverTime;

            if (!DateTime.TryParseExact(value, Template1, CultureInfo.InvariantCulture.DateTimeFormat,
                                        DateTimeStyles.None, out serverTime))
            {
                if (!DateTime.TryParseExact(value, Template2, CultureInfo.InvariantCulture.DateTimeFormat,
                                            DateTimeStyles.None, out serverTime))
                {
                    if (!DateTime.TryParseExact(value, Template3, CultureInfo.InvariantCulture.DateTimeFormat,
                                                DateTimeStyles.None, out serverTime))
                    {
                        wmDate = default(WmDate);
                        return(false);
                    }
                }
            }

            serverTime = new DateTime(serverTime.Year, serverTime.Month, serverTime.Day, 0, 0, 0);
            wmDate     = new WmDate(WmDateTime.ServerTime2UtcTime(serverTime));
            return(true);
        }
Example #2
0
        public static bool TryParse(string value, out WmDateTime wmDateTime)
        {
            if (string.IsNullOrEmpty(value))
            {
                wmDateTime = default(WmDateTime);
                return(false);
            }

            DateTime dateTime;

            if (
                !DateTime.TryParseExact(value, LocalTemplate, CultureInfo.InvariantCulture.DateTimeFormat,
                                        DateTimeStyles.None, out dateTime))
            {
                wmDateTime = default(WmDateTime);
                return(false);
            }

            wmDateTime = dateTime;
            return(true);
        }
Example #3
0
 public bool Equals(WmDateTime other)
 {
     return(_utcTime.Equals(other._utcTime));
 }
        internal string ToServerString(string format)
        {
            DateTime serverDate = WmDateTime.UtcTime2ServerTime(_utcTime);

            return(serverDate.ToString(format, CultureInfo.InvariantCulture.DateTimeFormat));
        }