Esempio n. 1
0
 public string ToFormatedString(DateTimeSscFormats format, bool includeTime)
 {
     if (includeTime)
     {
         return(ToFormatedString(format, true, "HH:mm:ss"));
     }
     else
     {
         return(ToFormatedString(format, false, ""));
     }
 }
Esempio n. 2
0
        private string ToFormatedString(DateTimeSscFormats format, bool includeTime, string timeFormat)
        {
            string r = "";

            if (DateTime != null)
            {
                System.DateTime date1 = DateTime.Value;
                //switch (displayKind)
                //{
                //    case DateTimeKind.Utc:
                //        date1 = date1.ToUniversalTime();
                //        break;
                //    case DateTimeKind.Local:
                //    default:
                //        date1 = date1.ToLocalTime();
                //        break;
                //}

                switch (format)
                {
                case DateTimeSscFormats.DayOfWeekAndShortDate:
                    r = _ToShortDateString() + " " + GetDayOfWeekName();
                    break;

                case DateTimeSscFormats.DayOfWeekAndMediumDate:
                    r = GetDayOfWeekName() + " " + Day.ToString() + " " + GetMonthName() + " " + Year.ToString();
                    break;

                case DateTimeSscFormats.MediumDate:
                    r = Day.ToString() + " " + GetMonthName() + " " + Year.ToString();
                    break;

                case DateTimeSscFormats.ShortDate:
                    r = _ToShortDateString();
                    break;

                case DateTimeSscFormats.Year:
                    r = Year.ToString();
                    break;

                case DateTimeSscFormats.Month:
                    r = Month.ToString();
                    break;

                case DateTimeSscFormats.DayOfWeek:
                    r = GetDayOfWeekName();
                    break;

                case DateTimeSscFormats.MonthName:
                    r = GetMonthName();
                    break;

                case DateTimeSscFormats.YearAndMonth:
                    r = Year.ToString() + " " + Month.ToString();
                    break;

                case DateTimeSscFormats.YearAndMonthName:
                    r = Year.ToString() + " " + GetMonthName();
                    break;

                default:
                    break;
                }
                if (includeTime)
                {
                    r += " ";
                    if (string.IsNullOrEmpty(timeFormat))
                    {
                        r += date1.ToString("t");
                    }
                    else
                    {
                        r += date1.ToString(timeFormat);
                    }
                }
            }
            return(r);
        }
Esempio n. 3
0
 public string ToFormatedString(DateTimeSscFormats format, string timeFormat)
 {
     return(ToFormatedString(format, true, timeFormat));
 }