fCraft.DateTimeUtil.TryParseDateTime C# (CSharp) Method

TryParseDateTime() public static method

Creates a DateTime from a UTC Unix Timestamp.
public static TryParseDateTime ( long timestamp ) : System.DateTime
timestamp long
return System.DateTime
        public static DateTime TryParseDateTime( long timestamp ) {
            return UnixEpoch.AddSeconds( timestamp );
        }

Same methods

DateTimeUtil::TryParseDateTime ( [ str, System.DateTime &result ) : bool

Usage Example

Example #1
0
        internal static IPBanInfo LoadFormat2([NotNull] string[] fields)
        {
            if (fields == null)
            {
                throw new ArgumentNullException("fields");
            }
            if (fields.Length != 8)
            {
                throw new ArgumentException("Unexpected field count", "fields");
            }
            IPBanInfo info = new IPBanInfo {
                Address  = IPAddress.Parse(fields[0]),
                BannedBy = PlayerDB.Unescape(fields[1])
            };

            DateTimeUtil.TryParseDateTime(fields[2], ref info.BanDate);
            if (fields[3].Length > 0)
            {
                info.BanReason = PlayerDB.Unescape(fields[3]);
            }
            if (fields[4].Length > 0)
            {
                info.PlayerName = PlayerDB.Unescape(fields[4]);
            }

            Int32.TryParse(fields[5], out info.Attempts);
            info.LastAttemptName = PlayerDB.Unescape(fields[6]);
            if (info.LastAttemptName.Length == 0)
            {
                info.LastAttemptName = null;
            }
            DateTimeUtil.TryParseDateTime(fields[7], ref info.LastAttemptDate);

            return(info);
        }
All Usage Examples Of fCraft.DateTimeUtil::TryParseDateTime