public static string GetLevelName(DateTime date, DateTimeLevels level) { switch (level) { case DateTimeLevels.DAY: return(date.ToString("dd")); case DateTimeLevels.DATE: return(date.ToString("yyyy-MM-dd")); case DateTimeLevels.YEAR: return(date.ToString("yyyy")); case DateTimeLevels.MONTH: return(date.ToString("MMMM")); case DateTimeLevels.MONTH_WITH_YEAR: return(date.ToString("yyyy MMMM")); case DateTimeLevels.WEEK: return(string.Format("{0} Week {1}", date.ToString("yyyy"), DateToWeek(date))); case DateTimeLevels.QUARTER: return(string.Format("{0} Q{1}", date.ToString("yyyy"), DateToQuarter(date))); default: throw new Exception("Level not supported."); } }
public static T TransformToDateId <T>(DateTime date, DateTimeLevels level) where T : struct, IComparable { switch (level) { case DateTimeLevels.DAY: return(TransformToDay <T>(date)); case DateTimeLevels.DATE: return(TransformToDate <T>(date)); case DateTimeLevels.MONTH_WITH_YEAR: return(TransformToMonth <T>(date)); case DateTimeLevels.YEAR: return(TransformToYear <T>(date)); case DateTimeLevels.QUARTER: return(TransformToQuarter <T>(date)); case DateTimeLevels.WEEK: return(TransformToWeek <T>(date)); case DateTimeLevels.MONTH: return(TransformToMonthOfYear <T>(date)); default: throw new Exception("Type not supported."); } }
// private MemberDateTimeCollection<T> _members; public DimensionDateTime(DimensionConfig dimconfig, DateTimeLevels level, int levelIndex) { typeOf = DimensionType.Date; this.Config = dimconfig; DateLevel = level; _level = levelIndex; LevelDimensions = new List <DimensionDateTime <T> >(); }