public static ListItem GetListItem(EDateFormatType type, bool selected)
        {
            var item = new ListItem(GetText(type), GetValue(type));

            if (selected)
            {
                item.Selected = true;
            }
            return(item);
        }
 public static bool Equals(EDateFormatType type, string typeStr)
 {
     if (string.IsNullOrEmpty(typeStr))
     {
         return(false);
     }
     if (string.Equals(GetValue(type).ToLower(), typeStr.ToLower()))
     {
         return(true);
     }
     return(false);
 }
 public static string GetText(EDateFormatType type)
 {
     if (type == EDateFormatType.Month)
     {
         return("6月18日");
     }
     if (type == EDateFormatType.Day)
     {
         return("2006-6-18");
     }
     if (type == EDateFormatType.Year)
     {
         return("2006年6月");
     }
     if (type == EDateFormatType.Chinese)
     {
         return("2006年6月18日");
     }
     throw new Exception();
 }
 public static string GetValue(EDateFormatType type)
 {
     if (type == EDateFormatType.Month)
     {
         return("Month");
     }
     if (type == EDateFormatType.Day)
     {
         return("Day");
     }
     if (type == EDateFormatType.Year)
     {
         return("Year");
     }
     if (type == EDateFormatType.Chinese)
     {
         return("Chinese");
     }
     throw new Exception();
 }
Exemple #5
0
        public static string GetDateString(DateTime datetime, EDateFormatType dateFormat)
        {
            var format = string.Empty;

            if (dateFormat == EDateFormatType.Year)
            {
                format = "yyyy年MM月";
            }
            else if (dateFormat == EDateFormatType.Month)
            {
                format = "MM月dd日";
            }
            else if (dateFormat == EDateFormatType.Day)
            {
                format = "yyyy-MM-dd";
            }
            else if (dateFormat == EDateFormatType.Chinese)
            {
                format = "yyyy年M月d日";
            }
            return(datetime.ToString(format));
        }
 public static bool Equals(string typeStr, EDateFormatType type)
 {
     return(Equals(type, typeStr));
 }
Exemple #7
0
 public static string GetDateAndTimeString(DateTime datetime, EDateFormatType dateFormat, ETimeFormatType timeFormat)
 {
     return($"{GetDateString(datetime, dateFormat)} {GetTimeString(datetime, timeFormat)}");
 }