RemObjects.InternetPack.Ftp.FtpListingItem.FtpDateToString C# (CSharp) Method

FtpDateToString() public static method

public static FtpDateToString ( System.DateTime date ) : String
date System.DateTime
return String
		public static String FtpDateToString(DateTime date)
		{
			Boolean lShowYear = (DateTime.Now - date).Days > 180;
			String lResult;

			switch (date.Month)
			{

				case 1:
					lResult = "Jan";
					break;

				case 2:
					lResult = "Feb";
					break;

				case 3:
					lResult = "Mar";
					break;

				case 4:
					lResult = "Apr";
					break;

				case 5:
					lResult = "May";
					break;

				case 6:
					lResult = "Jun";
					break;

				case 7:
					lResult = "Jul";
					break;

				case 8:
					lResult = "Aug";
					break;

				case 9:
					lResult = "Sep";
					break;

				case 10:
					lResult = "Oct";
					break;

				case 11:
					lResult = "Nov";
					break;

				case 12:
					lResult = "Dec";
					break;

				default:
					return "";
			}

			lResult += date.Day > 9 ? " " + date.Day : "  " + date.Day;

			if (lShowYear)
			{
				lResult += "  " + LeadZero(date.Year.ToString(), 4);
			}
			else
			{
				lResult += " ";
				if (date.Hour < 10) { lResult += "0"; }
				lResult += date.Hour.ToString();
				lResult += ":";
				if (date.Minute < 10) { lResult += "0"; }
				lResult += date.Minute.ToString();
			}

			return lResult;
		}

Usage Example

Exemplo n.º 1
0
        public override String ToString()
        {
            Char[] lRights = new Char[] { 'd', 'r', 'w', 'x', 'r', 'w', 'x', 'r', 'w', 'x' };

            if (!this.Directory)
            {
                lRights[0] = '-';
            }

            if (!this.UserRead)
            {
                lRights[1] = '-';
            }

            if (!this.UserWrite)
            {
                lRights[2] = '-';
            }

            if (!this.UserExec)
            {
                lRights[3] = '-';
            }

            if (!this.GroupRead)
            {
                lRights[4] = '-';
            }

            if (!this.GroupWrite)
            {
                lRights[5] = '-';
            }

            if (!this.GroupExec)
            {
                lRights[6] = '-';
            }

            if (!this.OtherRead)
            {
                lRights[7] = '-';
            }

            if (!this.OtherWrite)
            {
                lRights[8] = '-';
            }

            if (!this.OtherExec)
            {
                lRights[9] = '-';
            }

            return(String.Format("{0} {1,3} {2,8} {3,8} {4,7} {5} {6}", new String(lRights), this.SubItemCount, this.User,
                                 this.Group, this.Size, FtpListingItem.FtpDateToString(this.FileDate), this.FileName));
        }