コード例 #1
0
        public static string GetDateString(DateTimeOffset date, DateStringFormat format)
        {
            switch (format)
            {
            default:
            case DateStringFormat.Short:
                return(GetShortDateString(date));

            case DateStringFormat.Long:
                return(GetLongDateString(date));
            }
        }
コード例 #2
0
        public async Task <string> GetDateStringAsync(DateTimeOffset?date, DateStringFormat format = DateStringFormat.Long)
        {
            if (date.HasValue)
            {
                if (Config.GenerationsEnabled)
                {
                    IGeneration gen = await Db.GetGenerationByDateAsync(date.Value);

                    return(gen is null ? "Gen ???" : gen.Name);
                }

                return(DateUtilities.GetDateString(date.Value, format));
            }
            else
            {
                return("???");
            }
        }
コード例 #3
0
 public static string GetDateString(long timestamp, DateStringFormat format)
 {
     return(GetDateString(GetDateFromTimestamp(timestamp), format));
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FormattedDateAttribute" /> class.
 /// </summary>
 /// <param name="dateProperty">The date property.</param>
 /// <param name="formatType">Type of the format.</param>
 public FormattedDateAttribute(string dateProperty, DateStringFormat formatType)
 {
     this.DateProperty = dateProperty;
     this.FormatType   = formatType;
 }