public LocalExtremeController(IDateRange dateRange, IExtremesServices extremesServices, IDateChecker dateChecker, ICurrenciesSelectList currenciesSelectList)
 {
     _extremeServices      = extremesServices;
     _dateChecker          = dateChecker;
     _currenciesSelectList = currenciesSelectList;
     _dateRange            = dateRange;
 }
예제 #2
0
        public IEnumerable <TicketEM> GetTickets(IDateRange dateRange)
        {
            var param = ParametersHelper.CreateFromObject(dateRange);

            return(ExecuteSP <TicketEM, PackageEM, SerialEM, ColorEM, NominalEM, TicketEM>("USP_Ticket_GetBetweenDates",
                                                                                           TicketEM.MapTicket, SPLIT_ON, param));
        }
예제 #3
0
        private void SetUpGanttData()
        {
            this.VisibleRange = new DateRange(DateTime.Today, DateTime.Today.AddDays(15));
            this.Tasks = new ObservableCollection<IGanttTask>();

            var start = DateTime.Today;
            var end = start.AddDays(3);

            var testingTaskChild1 = new GanttTask(start, end, "Unit test planning");
            var testingTaskChild2 = new GanttTask(start.AddDays(1), end.AddDays(2), "Integration test planning");

            start = start.AddDays(3);
            end = start.AddDays(4);
            var testingTaskChild3 = new GanttTask(start, end, "Unit testing");

            start = end.Date.AddHours(1);
            end = start.AddDays(2);
            var testingTaskChild4 = new GanttTask(start, end, "Integration Testing");

            testingTaskChild2.Dependencies.Add(new Dependency { FromTask = testingTaskChild1 });
            testingTaskChild3.Dependencies.Add(new Dependency { FromTask = testingTaskChild2 });
            testingTaskChild4.Dependencies.Add(new Dependency { FromTask = testingTaskChild3 });

            start = DateTime.Today;
            end = start.AddDays(4);

            var testingTask = new GanttTask(start, end, "Testing")
            {
                Children = { testingTaskChild1, testingTaskChild2, testingTaskChild3, testingTaskChild4 }
            };

            this.Tasks.Add(testingTask);
        }
        private bool Equals(IDateRange <DateTime> dateRange)
        {
            bool isStartSame = false;
            bool isEndSame   = false;

            if (dateRange.Start.HasValue != Start.HasValue ||
                dateRange.End.HasValue != dateRange.End.HasValue)
            {
                return(false);
            }

            if (!dateRange.Start.HasValue && !Start.HasValue ||
                dateRange.Start.Equals(Start.Value))
            {
                isStartSame = true;
            }

            if (!dateRange.End.HasValue && !End.HasValue ||
                dateRange.End.Equals(End.Value))
            {
                isEndSame = true;
            }

            return(isEndSame && isStartSame);
        }
		public ViewModel()
		{
            var start = new DateTime(DateTime.Today.Year, Math.Max(1, DateTime.Today.Month - 1), 1);
			var end = start.AddMonths(5);
			this.visibleRange = new DateRange(start, end);

			this.FilteringCommand = new DelegateCommand(this.FilteringExecuted);
		}
		public IEnumerable<IDateRange> GetRanges(IDateRange visibleRange)
		{
			var now = DateTime.Now;
			if (now > visibleRange.Start)
			{
				yield return new DateRange(visibleRange.Start, now < visibleRange.End ? now : visibleRange.End);
			}
		}
 private void ValidateDateRange(IDateRange rng)
 {
     // Calculate the correct time format (AM/PM)
     if (rng.Start >= rng.End)
     {
         throw new Exception("Error: Please make sure your start time and end time are correct.");
     }
 }
예제 #8
0
        public PaymentsReportViewModel(IDataService dataService)
        {
            _dataService = dataService;
            var dateRangeSupplier = new DateRangeSupplier();

            DateRanges     = new List <IDateRange>(dateRangeSupplier.getDateRanges());
            _lastDateRange = DateRanges[DateRanges.Count - 1];
        }
 public CurrencyComparisionController(ICurrenciesComparator currenciesComparator, IDateRange dateRange, IDateChecker dateChecker
                                      , ICurrencyNameChecker currencyNameChecker, ICurrenciesSelectList currenciesSelectList)
 {
     _currenciesComparator = currenciesComparator;
     _dateChecker          = dateChecker;
     _dateRange            = dateRange;
     _currencyNameChecker  = currencyNameChecker;
     _currenciesSelectList = currenciesSelectList;
 }
예제 #10
0
 public CurrencyConversionController(IDateRange dateRange, IDateChecker dateChecker
                                     , ICurrencyConversionService currencyConversionService, ICurrencyNameChecker currencyNameChecker, ICurrenciesSelectList currenciesSelectList)
 {
     _currencyConversionService = currencyConversionService;
     _dateChecker          = dateChecker;
     _dateRange            = dateRange;
     _currencyNameChecker  = currencyNameChecker;
     _currenciesSelectList = currenciesSelectList;
 }
예제 #11
0
 public bool Encompases(IDateRange <Date> other)
 {
     if (other == null)
     {
         throw new ArgumentNullException(nameof(other));
     }
     return((BeginDate == null || (other.BeginDate != null && Contains(other.BeginDate))) &&
            (EndDate == null || (other.EndDate != null && Contains(other.EndDate))));
 }
예제 #12
0
        public static IEnumerable <DateTime> AsEnumerable([NotNull] this IDateRange range)
        {
            if (range == null)
            {
                throw new ArgumentNullException(nameof(range));
            }
            var daysInRange = (range.End - range.Start).Days + 1;

            return(Enumerable.Range(0, daysInRange).Select(x => range.Start.AddDays(x)));
        }
예제 #13
0
 public bool Overlaps(IDateRange <Date> other)
 {
     if (other == null)
     {
         throw new ArgumentNullException(nameof(other));
     }
     return(IsUnbounded ||
            (other.BeginDate != null && Contains(other.BeginDate)) ||
            (other.EndDate != null && Contains(other.EndDate)));
 }
예제 #14
0
        public static IRule BetweenValidation(string propname, IDateRange range, ValidationSeverity severity = ValidationSeverity.Critical)
        {
            ClientSideValidationRule <DateTime, IDateRange> newValidation = new ClientSideValidationRule <DateTime, IDateRange>("Date Between",
                                                                                                                                "Date must be between " + range.FirstValidDate.ToString() + " and " + range.LastValidDate.ToString() + ".",
                                                                                                                                propname,
                                                                                                                                CommonPropRuleHandlers.DateRangeHandler);

            newValidation.AllowedValue = range;
            newValidation.Severity     = severity;
            return(newValidation);
        }
예제 #15
0
        private void PopulateDateRange(IDateRange value)
        {
            var year = DateTime.Now.Year;

            if (DateTime.Now.Month < 3)
            {
                year--;
            }

            value.From = new DateTime(year, 1, 1);
            value.To   = value.From.AddYears(1).AddDays(-1);
        }
		public System.Collections.Generic.IEnumerable<IDateRange> GetRanges(IDateRange visibleRange)
		{
			for (DateTime current = visibleRange.Start; current < visibleRange.End; current += TimeSpan.FromDays(1))
			{
				int addDays = (int)current.DayOfWeek;
				if (addDays < 7 && (int)current.DayOfWeek % 2 != 0)
				{
					yield return new DateRange(current, current.AddDays(Math.Min((visibleRange.End - current).Days, 1)));
					addDays = addDays + 1;
				}
			}
		}
예제 #17
0
 /// <param name="dateRange">A date range to determine the difference of</param>
 public DateDifference(IDateRange dateRange)
 {
     if (dateRange.Start <= dateRange.End)
     {
         _earlier = dateRange.Start;
         _later = dateRange.End;
     }
     else
     {
         _earlier = dateRange.End;
         _later = dateRange.Start;
     }
 }
예제 #18
0
        public System.Collections.Generic.IEnumerable <IDateRange> GetRanges(IDateRange visibleRange)
        {
            for (DateTime current = visibleRange.Start; current < visibleRange.End; current += TimeSpan.FromDays(1))
            {
                int addDays = (int)current.DayOfWeek;
                if (addDays < 7 && (int)current.DayOfWeek % 2 != 0)
                {
                    yield return(new DateRange(current, current.AddDays(1)));

                    addDays = addDays + 1;
                }
            }
        }
예제 #19
0
        private void SetCustomRange(IDateRange dateRange)
        {
            if (null == dateRange)
            {
                throw new ArgumentNullException(nameof(dateRange));
            }

            var custom      = GetItemByKind(DateRangeKind.Custom);
            var customIndex = IndexOf(custom);
            var forceCustom = true;

            this[customIndex] = new RangePresenter(custom.ResourceManager, dateRange, forceCustom);

            Current = this[customIndex];
        }
예제 #20
0
            public void Test_SingleDate_ForBangladeshCulture_ReturnsDateRangeDay()
            {
                // Arrange
                const string firstDate = "09-11-17";

                string[] inputArray = new string[1] {
                    firstDate
                };
                Type expectedResult = typeof(DateRangeSameDay);

                // Act
                IDateRange actualResult = this._dateRange.From(inputArray, this._currentCulture);

                // Assert
                Assert.AreEqual(expectedResult, actualResult.GetType());
            }
예제 #21
0
            public void Test_IfSameDate_ForBangladeshCulture_ReturnsProperToStringRange()
            {
                // Arrange
                const string firstDate = "09-11-17";

                string[] inputArray = new string[1] {
                    firstDate
                };
                const string expectedResult = "09-11-17";

                // Act
                IDateRange actualResult = this._dateRange.From(inputArray, this._currentCulture);

                // Assert
                Assert.AreEqual(expectedResult, actualResult.ToString());
            }
        public int CompareTo(IDateRange <DateTimeOffset> other)
        {
            var compareIndex = 0;

            if (Start.HasValue && other.Start.HasValue)
            {
                compareIndex += Start.Value.CompareTo(other.Start.Value);
            }

            if (End.HasValue && other.End.HasValue)
            {
                compareIndex += Start.Value.CompareTo(other.Start.Value);
            }

            return(compareIndex);
        }
예제 #23
0
            public void Test_IfTwoDifferentDates_ForBangladeshCulture_ReturnsProperToStringRange()
            {
                // Arrange
                const string firstDate  = "15-10-17";
                const string secondDate = "20-11-18";

                string[] inputArray = new string[2] {
                    firstDate, secondDate
                };
                const string expectedResult = "15-10-17 — 20-11-18";

                // Act
                IDateRange actualResult = this._dateRange.From(inputArray, this._currentCulture);

                // Assert
                Assert.AreEqual(expectedResult, actualResult.ToString());
            }
예제 #24
0
            public void Test_IfTwoDifferentDates_ForAfrikaansCulture_ReturnsProperToStringRange()
            {
                // Arrange
                const string firstDate  = "2017/10/15";
                const string secondDate = "2018/11/20";

                string[] inputArray = new string[2] {
                    firstDate, secondDate
                };
                const string expectedResult = "2017/10/15 — 2018/11/20";

                // Act
                IDateRange actualResult = this._dateRange.From(inputArray, this._currentCulture);

                // Assert
                Assert.AreEqual(expectedResult, actualResult.ToString());
            }
예제 #25
0
            public void Test_IfTwoDifferentDates_ForGermanCulture_ReturnsDateRangeVarious()
            {
                // Arrange
                const string firstDate  = "15.10.2017";
                const string secondDate = "20.11.2018";

                string[] inputArray = new string[2] {
                    firstDate, secondDate
                };
                Type expectedResult = typeof(DateRangeVarious);

                // Act
                IDateRange actualResult = this._dateRange.From(inputArray, this._currentCulture);

                // Assert
                Assert.AreEqual(expectedResult, actualResult.GetType());
            }
예제 #26
0
            public void Test_IfTwoSameDates_ForPolishCulture_ReturnsProperToStringRange()
            {
                // Arrange
                const string firstDate  = "2017-11-09";
                const string secondDate = "2017-11-09";

                string[] inputArray = new string[2] {
                    firstDate, secondDate
                };
                const string expectedResult = "2017-11-09";

                // Act
                IDateRange actualResult = this._dateRange.From(inputArray, this._currentCulture);

                // Assert
                Assert.AreEqual(expectedResult, actualResult.ToString());
            }
예제 #27
0
            public void Test_IfTwoDatesWithSameMonth_ForPolishCulture_ReturnsDateRangeMonth()
            {
                // Arrange
                const string firstDate  = "2017-11-15";
                const string secondDate = "2017-11-20";

                string[] inputArray = new string[2] {
                    firstDate, secondDate
                };
                Type expectedResult = typeof(DateRangeSameMonth);

                // Act
                IDateRange actualResult = this._dateRange.From(inputArray, this._currentCulture);

                // Assert
                Assert.AreEqual(expectedResult, actualResult.GetType());
            }
예제 #28
0
            public void Test_IfTwoDatesWithSameYear_ForBangladeshCulture_ReturnsDateRangeYear()
            {
                // Arrange
                const string firstDate  = "15-10-17";
                const string secondDate = "20-11-17";

                string[] inputArray = new string[2] {
                    firstDate, secondDate
                };
                Type expectedResult = typeof(DateRangeSameYear);

                // Act
                IDateRange actualResult = this._dateRange.From(inputArray, this._currentCulture);

                // Assert
                Assert.AreEqual(expectedResult, actualResult.GetType());
            }
예제 #29
0
            public void Test_IfTwoDatesWithSameYear_ForGermanCulture_ReturnsProperToStringRange()
            {
                // Arrange
                const string firstDate  = "15.10.2017";
                const string secondDate = "20.11.2017";

                string[] inputArray = new string[2] {
                    firstDate, secondDate
                };
                const string expectedResult = "15.10 — 20.11.2017";

                // Act
                IDateRange actualResult = this._dateRange.From(inputArray, this._currentCulture);

                // Assert
                Assert.AreEqual(expectedResult, actualResult.ToString());
            }
예제 #30
0
            public void Test_IfThreeDifferentDates_ForGermanCulture_ReturnsProperToStringRange()
            {
                // Arrange
                const string firstDate  = "15.10.2017";
                const string secondDate = "20.11.2018";
                const string thirdDate  = "25.12.2019";

                string[] inputArray = new string[3] {
                    firstDate, secondDate, thirdDate
                };
                const string expectedResult = "15.10.2017 — 25.12.2019";

                // Act
                IDateRange actualResult = this._dateRange.From(inputArray, this._currentCulture);

                // Assert
                Assert.AreEqual(expectedResult, actualResult.ToString());
            }
예제 #31
0
            public void Test_IfThreeDatesWithSameMonth_ForBangladeshCulture_ReturnsProperToStringRange()
            {
                // Arrange
                const string firstDate  = "15-11-17";
                const string secondDate = "20-11-17";
                const string thirdDate  = "25-11-17";

                string[] inputArray = new string[3] {
                    firstDate, secondDate, thirdDate
                };
                const string expectedResult = "15—25-11-17";

                // Act
                IDateRange actualResult = this._dateRange.From(inputArray, this._currentCulture);

                // Assert
                Assert.AreEqual(expectedResult, actualResult.ToString());
            }
예제 #32
0
            public void Test_IfThreeDifferentDates_ForPolishCulture_ReturnsProperToStringRange()
            {
                // Arrange
                const string firstDate  = "2017-10-15";
                const string secondDate = "2018-11-20";
                const string thirdDate  = "2019-12-25";

                string[] inputArray = new string[3] {
                    firstDate, secondDate, thirdDate
                };
                const string expectedResult = "2017-10-15 — 2019-12-25";

                // Act
                IDateRange actualResult = this._dateRange.From(inputArray, this._currentCulture);

                // Assert
                Assert.AreEqual(expectedResult, actualResult.ToString());
            }
예제 #33
0
            public void Test_IfThreeDatesWithSameYear_ForAmericanCulture_ReturnsProperToStringRange()
            {
                // Arrange
                const string firstDate  = "10/15/2017";
                const string secondDate = "11/20/2017";
                const string thirdDate  = "12/25/2017";

                string[] inputArray = new string[3] {
                    firstDate, secondDate, thirdDate
                };
                const string expectedResult = "10/15 — 12/25/2017";

                // Act
                IDateRange actualResult = this._dateRange.From(inputArray, this._currentCulture);

                // Assert
                Assert.AreEqual(expectedResult, actualResult.ToString());
            }
        public void Start(string[] inputArray)
        {
            CultureInfo currentCulture = CultureInfo.CurrentCulture;

            ValidationController validator = new ValidationController();

            try
            {
                DateRangeFactory dateRange = new DateRangeFactory(validator);
                IDateRange       result    = dateRange.From(inputArray, currentCulture);

                DisplayController.Display(DisplayController.SetMessageColor(MonitOperationSucceed,
                                                                            DisplayController.Color.DarkGreen));
                DisplayController.Display(result.ToString());
            }
            catch (Exception exception)
            {
                DisplayController.Display(exception.Message);
            }
            Console.ReadKey();
        }
예제 #35
0
        private void SetUpGanttData()
        {
            this.VisibleRange = new DateRange(DateTime.Today, DateTime.Today.AddDays(15));
            this.Tasks        = new ObservableCollection <IGanttTask>();

            var start = DateTime.Today;
            var end   = start.AddDays(3);

            var testingTaskChild1 = new GanttTask(start, end, "Unit test planning");
            var testingTaskChild2 = new GanttTask(start.AddDays(1), end.AddDays(2), "Integration test planning");

            start = start.AddDays(3);
            end   = start.AddDays(4);
            var testingTaskChild3 = new GanttTask(start, end, "Unit testing");

            start = end.Date.AddHours(1);
            end   = start.AddDays(2);
            var testingTaskChild4 = new GanttTask(start, end, "Integration Testing");

            testingTaskChild2.Dependencies.Add(new Dependency {
                FromTask = testingTaskChild1
            });
            testingTaskChild3.Dependencies.Add(new Dependency {
                FromTask = testingTaskChild2
            });
            testingTaskChild4.Dependencies.Add(new Dependency {
                FromTask = testingTaskChild3
            });

            start = DateTime.Today;
            end   = start.AddDays(4);

            var testingTask = new GanttTask(start, end, "Testing")
            {
                Children = { testingTaskChild1, testingTaskChild2, testingTaskChild3, testingTaskChild4 }
            };

            this.Tasks.Add(testingTask);
        }
예제 #36
0
        /// <summary>
        ///     Determines if the specified <paramref name="dateTime" /> is within the given <paramref name="dateRange" />
        /// </summary>
        /// <param name="dateTime">The DateTime to look for within <paramref name="dateRange" /></param>
        /// <param name="dateRange">The date range to look in</param>
        /// <param name="allowSameEndPoints">
        ///     Determines whether the beginning and end of <paramref name="dateRange" /> can equal
        ///     <paramref name="dateTime" />
        /// </param>
        /// <returns>True if <paramref name="dateTime" /> is within <paramref name="dateRange" /></returns>
        public static bool Within(this DateTime dateTime, IDateRange dateRange, bool allowSameEndPoints = true)
        {
            if (dateRange == null)
                return false;

            return allowSameEndPoints
                       ? dateTime > dateRange.Start && dateTime < dateRange.End
                       : dateTime >= dateRange.Start && dateTime <= dateRange.End;
        }
		public ViewModel()
		{
			this.visibleRange = new DateRange(this.today, this.today.AddDays(5));
			this.LoadData();
		}
		private void SetSelectedItem(IDateRange visibleRange)
		{
			var firstVisibleTask = this.tasks.Where(t => t.End >= visibleRange.Start).FirstOrDefault();
			if (firstVisibleTask != null)
			{
				this.SelectedItem = firstVisibleTask;
			}
		}
예제 #39
0
        /// <inheritdoc cref="Within(DateTime, IDateRange, bool)" />
        public static bool Within(this DateTime? dateTime, IDateRange dateRange, bool allowSameEndPoints = true)
        {
            if (dateRange == null)
                return false;

            return dateTime?.Within(dateRange, allowSameEndPoints) ?? false;
        }
		private void InitializeData()
		{
			this.startDate = new DateTime(1970, 1, 1);
			this.endDate = DateTime.Today;
			this.selectedMovie = this.movies.First();
			this.visibleRange = new DateRange(selectedMovie.StartFilmingDate, DateTime.Today);
		}
예제 #41
0
        /// <inheritdoc cref="Date.Overlaps(DateTime, DateTime, DateTime, DateTime, bool)" />
        /// <param name="dateRange">The date range compare</param>
        /// <param name="compareRange">The date range to compare to</param>
        public static bool Overlaps(this IDateRange dateRange, IDateRange compareRange, bool allowSameEndPoints = true)
        {
            if (dateRange == null || compareRange == null)
                return false;

            return Date.Overlaps(dateRange.Start, dateRange.End, compareRange.Start, compareRange.End, allowSameEndPoints);
        }
예제 #42
0
        /// <inheritdoc cref="Overlaps(IDateRange, IDateRange, bool)" />
        public static bool Overlaps(this IOpenEndedDateRange dateRange, IDateRange compareRange, bool allowSameEndPoints = true)
        {
            if (dateRange == null || compareRange == null)
                return false;

            if (dateRange.End.HasValue)
                return Date.Overlaps(dateRange.Start, dateRange.End.Value, compareRange.Start, compareRange.End, allowSameEndPoints);

            ValidityCheck(dateRange);
            ValidityCheck(compareRange);

            return allowSameEndPoints
                       ? compareRange.Start > dateRange.Start || compareRange.End > dateRange.Start
                       : compareRange.Start >= dateRange.Start || compareRange.End >= dateRange.Start;
        }
예제 #43
0
 private static void ValidityCheck(IDateRange dateRange)
 {
     if (dateRange != null)
         ValidityCheck(dateRange.Start, dateRange.End);
 }