BitServer.UnixTime.ConvertFrom C# (CSharp) Method

ConvertFrom() public static method

public static ConvertFrom ( int unix ) : System.DateTime
unix int
return System.DateTime
        public static DateTime ConvertFrom(int unix)
        {
            if (unix > 0)
            {
                return UNIX.AddSeconds(unix);
            }
            //works until 7 Feb 2106
            return OVERFLOW.AddSeconds(int.MaxValue - unix);
        }

Usage Example

Example #1
0
        public POP3message(int ID, BitMsg MSG, BitAddr[] LocalAddr)
        {
            string rec = MSG.toAddress.Replace(BR_SUB, BR);

            if (rec == BR)
            {
                rec = string.Format("'Broadcast subscribers' <{0}@{1}>", BR, Program.BS.Extension);
            }
            else
            {
                foreach (BitAddr a in LocalAddr)
                {
                    if (a.address == rec)
                    {
                        rec = string.Format("'{0}' <{1}@{2}>", a.label.Replace('"', '_'), rec, Program.BS.Extension);
                    }
                }
            }
            MSG.message.Replace("\r\n", "\n");
            if (!isMail(MSG.message))
            {
                //prepend Mail Headers
                Body += string.Format(@"Return-Path: {0}@{4}
To: {1}@{4}
From: {0}@{4}
Subject: {2}
Date: {3}
Received: {3}

", MSG.fromAddress, rec.Replace(BR_SUB, BR), MSG.subject, UnixTime.ConvertFrom(MSG.receivedTime).ToString("R"), Program.BS.Extension);
                Body += MSG.message;
            }
            else
            {
                //Valid Mail, use sent headers.
                if (isMailList(MSG.message))
                {
                    MSG.message = MSG.message.Substring(MSG.message.IndexOf('\n') + 1);
                    MSG.message = MSG.message.Substring(MSG.message.IndexOf('\n') + 1);
                    Body       += MSG.message;
                }
                else
                {
                    Body += MSG.message;
                }
            }
            UID     = MSG.msgid;
            Deleted = false;
        }