Exemplo n.º 1
0
        private EntityCollection<ExcludeMatchDateEntity> Map(Ical.Net.Calendar iCal, string defaultTimeZoneId, DateTimePeriod dateLimits)
        {
            var excluded = new EntityCollection<ExcludeMatchDateEntity>();
            
            // small come before big date ranges
            foreach (var calendarEvent in iCal.Events.OrderBy(e => e.DtStart.Date).ThenBy(e => e.Duration.Days))
            {
                var exclDate = CreateEntity(calendarEvent, defaultTimeZoneId);
                if (dateLimits.Contains(exclDate.DateFrom) || dateLimits.Contains(exclDate.DateTo))
                {
                    excluded.Add(CreateEntity(calendarEvent, defaultTimeZoneId));
                }
            }

            return excluded;
        }
Exemplo n.º 2
0
        public void op_Contains_DateTime(bool expected,
                                         string value)
        {
            var period = new DateTimePeriod(XmlConvert.ToDateTime("2012-11-01T00:00:00Z", XmlDateTimeSerializationMode.Utc),
                                            XmlConvert.ToDateTime("2012-11-30T23:59:59Z", XmlDateTimeSerializationMode.Utc));
            var actual = period.Contains(XmlConvert.ToDateTime(value, XmlDateTimeSerializationMode.Utc));

            Assert.Equal(expected, actual);
        }
Exemplo n.º 3
0
        private IEnumerable <ExcludeMatchDateEntity> Map(List <Axuno.Tools.GermanHoliday> holidays, DateTimePeriod dateLimits)
        {
            // sort short date ranges before big ranges
            var holidayGroups = holidays.ConsecutiveRanges()
                                .OrderBy(tuple => tuple.From.Date).ThenBy(tuple => (tuple.To - tuple.From).Days);

            foreach (var holidayGroup in holidayGroups)
            {
                var entity = CreateEntity(holidayGroup);
                if (!dateLimits.Contains(entity.DateFrom) && !dateLimits.Contains(entity.DateTo))
                {
                    continue;
                }

                // convert from import time zone to UTC
                entity.DateFrom = _timeZoneConverter.ToUtc(entity.DateFrom.Date);
                entity.DateTo   = _timeZoneConverter.ToUtc(entity.DateTo.AddDays(1).AddSeconds(-1));

                yield return(entity);
            }
        }
        public void Contains(DateTime?date1, DateTime?date2, DateTime contains, bool expected)
        {
            var dtp = new DateTimePeriod(date1, date2);

            Assert.AreEqual(expected, dtp.Contains(contains));
        }