/// <summary> /// Returns true if the smaller granularity is part of the biggest granularity /// </summary> /// <param name="smaller">Granularity</param> /// <param name="bigger">Granularity</param> public static bool IsPartOf(this Granularity smaller, Granularity bigger) { if (bigger == Granularity.Week) { return(smaller == Granularity.Day || smaller.IsPartOf(Granularity.Day)); } if (smaller == Granularity.Week) { return(false); } if (bigger == Granularity.FifteenMinute) { return(smaller == Granularity.Minute); } return(smaller._orderOf() < bigger._orderOf()); }
/// <summary> /// Returns true if the given Granularity is by time /// </summary> /// <param name="granularity">Granularity</param> public static bool IsTimeGranularity(this Granularity granularity) { return(granularity.IsPartOf(Granularity.Day)); }