More intuitive time range specification, than start date - end date type of date/time range. For example, "PreviousExcludingCurrent 3 quarters", "Current week", "Past 48 hours".
        public static DateRange Next(this TimeUnits unit, ulong unitCount, DateTime?referenceMoment)
        {
            var       span  = new RelativeTimeSpan(Timeline.NextExcludingCurrent, unit, unitCount);
            DateRange range = span.GetDateTimeRange(referenceMoment);

            return(range);
        }
        public static DateRange ToDate(this TimeUnits unit, DateTime?referenceMoment)
        {
            var       span  = new RelativeTimeSpan(Timeline.ToDateOrTillSpecified, unit);
            DateRange range = span.GetDateTimeRange(referenceMoment);

            return(range);
        }
        public static DateRange Current(this TimeUnits unit, DateTime?referenceMoment)
        {
            var       span  = new RelativeTimeSpan(Timeline.EntireCurrentOrSpecified, unit);
            DateRange range = span.GetDateTimeRange(referenceMoment);

            return(range);
        }
        /// <summary>
        /// Warning: bug found. dt.Offset may be incorrect as offsets could be different if range crosses daylight saving switch, i.e. October - December, or month of November in the EST USA.
        /// </summary>
        /// <param name="unit"></param>
        /// <param name="unitCount"></param>
        /// <param name="referenceMoment"></param>
        /// <returns></returns>
        public static TimeMomentRange Next(this TimeUnits unit, ulong unitCount = 1, DateTimeOffset?referenceMoment = null)
        {
            var             span  = new RelativeTimeSpan(Timeline.NextExcludingCurrent, unit, unitCount);
            TimeMomentRange range = span.GetTimeMomentRange(referenceMoment);

            return(range);
        }
        /// <summary>
        /// Warning: bug found. dt.Offset may be incorrect as offsets could be different if range crosses daylight saving switch, i.e. October - December, or month of November in the EST USA.
        /// </summary>
        /// <param name="unit"></param>
        /// <param name="referenceMoment"></param>
        /// <returns></returns>
        public static TimeMomentRange ToDate(this TimeUnits unit, DateTimeOffset?referenceMoment = null)
        {
            var             span  = new RelativeTimeSpan(Timeline.ToDateOrTillSpecified, unit);
            TimeMomentRange range = span.GetTimeMomentRange(referenceMoment);

            return(range);
        }
예제 #6
0
 public static DateRange ToDate(this TimeUnits unit, DateTime? referenceMoment)
 {
     var span = new RelativeTimeSpan(Timeline.ToDateOrTillSpecified, unit);
     DateRange range = span.GetDateTimeRange(referenceMoment);
     return range;
 }
예제 #7
0
 /// <summary>
 /// Warning: bug found. dt.Offset may be incorrect as offsets could be different if range crosses daylight saving switch, i.e. October - December, or month of November in the EST USA.
 /// </summary>
 /// <param name="unit"></param>
 /// <param name="referenceMoment"></param>
 /// <returns></returns>
 public static TimeMomentRange ToDate(this TimeUnits unit, DateTimeOffset? referenceMoment = null)
 {
     var span = new RelativeTimeSpan(Timeline.ToDateOrTillSpecified, unit);
     TimeMomentRange range = span.GetTimeMomentRange(referenceMoment);
     return range;
 }
예제 #8
0
 public static DateRange Previous(this TimeUnits unit, ulong unitCount, DateTime? referenceMoment)
 {
     var span = new RelativeTimeSpan(Timeline.PreviousExcludingCurrent, unit, unitCount);
     DateRange range = span.GetDateTimeRange(referenceMoment);
     return range;
 }
예제 #9
0
 /// <summary>
 /// Warning: bug found. dt.Offset may be incorrect as offsets could be different if range crosses daylight saving switch, i.e. October - December, or month of November in the EST USA.
 /// </summary>
 /// <param name="unit"></param>
 /// <param name="unitCount"></param>
 /// <param name="referenceMoment"></param>
 /// <returns></returns>
 public static TimeMomentRange Previous(this TimeUnits unit, ulong unitCount = 1, DateTimeOffset? referenceMoment = null)
 {
     var span = new RelativeTimeSpan(Timeline.PreviousExcludingCurrent, unit, unitCount);
     TimeMomentRange range = span.GetTimeMomentRange(referenceMoment);
     return range;
 }
예제 #10
0
 public static DateRange Future(this TimeUnits unit, ulong unitCount, DateTime? referenceMoment)
 {
     var span = new RelativeTimeSpan(Timeline.Future, unit, unitCount);
     DateRange range = span.GetDateTimeRange(referenceMoment);
     return range;
 }
예제 #11
0
 /// <summary>
 /// Warning: bug found. dt.Offset may be incorrect as offsets could be different if range crosses daylight saving switch, i.e. October - December, or month of November in the EST USA.
 /// </summary>
 /// <param name="unit"></param>
 /// <param name="unitCount"></param>
 /// <param name="referenceMoment"></param>
 /// <returns></returns>
 public static TimeMomentRange Future(this TimeUnits unit, ulong unitCount = 1, DateTimeOffset? referenceMoment = null)
 {
     var span = new RelativeTimeSpan(Timeline.Future, unit, unitCount);
     TimeMomentRange range = span.GetTimeMomentRange(referenceMoment);
     return range;
 }
예제 #12
0
 public static DateRange Current(this TimeUnits unit, DateTime? referenceMoment)
 {
     var span = new RelativeTimeSpan(Timeline.EntireCurrentOrSpecified, unit);
     DateRange range = span.GetDateTimeRange(referenceMoment);
     return range;
 }