当前位置: 首页>>代码示例>>C#>>正文


C# DateTimeRange类代码示例

本文整理汇总了C#中DateTimeRange的典型用法代码示例。如果您正苦于以下问题:C# DateTimeRange类的具体用法?C# DateTimeRange怎么用?C# DateTimeRange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DateTimeRange类属于命名空间,在下文中一共展示了DateTimeRange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestRoundRangeToInterval

        public void TestRoundRangeToInterval()
        {
            DateTime startDate = new DateTime(2008, 05, 1, 10, 2, 3, 4, DateTimeKind.Utc);
            DateTime startRounded1 = new DateTime(2008, 05, 1, 10, 2, 0, 0, DateTimeKind.Utc);
            DateTime startRounded15 = new DateTime(2008, 05, 1, 10, 0, 0, 0, DateTimeKind.Utc);
            DateTime endDate = new DateTime(2008, 05, 1, 11, 2, 3, 4, DateTimeKind.Utc);
            DateTime endRounded1 = new DateTime(2008, 05, 1, 11, 3, 0, 0, DateTimeKind.Utc);
            DateTime endRounded15 = new DateTime(2008, 05, 1, 11, 15, 0, 0, DateTimeKind.Utc);

            DateTimeRange range = new DateTimeRange(startDate, endDate);
            DateTimeRange rounded = DateUtil.RoundRangeToInterval(range, 1);
            Assert.AreEqual(rounded.Start, startRounded1);
            Assert.AreEqual(rounded.End, endRounded1);

            DateTimeRange twiceRounded = DateUtil.RoundRangeToInterval(rounded, 1);
            Assert.AreEqual(rounded.Start, twiceRounded.Start);
            Assert.AreEqual(rounded.End, twiceRounded.End);

            rounded = DateUtil.RoundRangeToInterval(range, 15);
            Assert.AreEqual(rounded.Start, startRounded15);
            Assert.AreEqual(rounded.End, endRounded15);

            twiceRounded = DateUtil.RoundRangeToInterval(rounded, 15);
            Assert.AreEqual(rounded.Start, twiceRounded.Start);
            Assert.AreEqual(rounded.End, twiceRounded.End);
        }
开发者ID:pkdevboxy,项目名称:calendar-connectors,代码行数:26,代码来源:DateUtilTest.cs

示例2: NotEqualSamePrecisionHourTest

 public void NotEqualSamePrecisionHourTest()
 {
     var d1 = new DateTimeRange(new DateTime(2011, 4, 4, 10, 34, 10), DateTimeRange.PrecisionType.Hours);
     var d2 = new DateTimeRange(new DateTime(2011, 4, 4, 11, 20, 10), DateTimeRange.PrecisionType.Hours);
     Assert.AreNotEqual(d1, d2);
     Assert.AreNotEqual(d2, d1);
 }
开发者ID:yash0924,项目名称:csharputils,代码行数:7,代码来源:DateTimeRangeTest.cs

示例3: TryGetCrossRange

        public bool TryGetCrossRange(DateTimeRange range, out DateTimeRange? crossRange)
        {
            crossRange = null;
            if (!IsIntersect(range)) return false;

            // Range полностью лежит в периоде
            if (range.Begin >= Begin && range.End <= End)
            {
                crossRange = range;
                return true;
            }

            // Период анализируемый период слева
            if (range.Begin < Begin && range.End <= End)
            {
                crossRange = new DateTimeRange(Begin, range.End);
                return true;
            }

            // Период нарушения пересекает период справа
            if (range.Begin >= Begin && range.End > End)
            {
                crossRange = new DateTimeRange(range.Begin, End);
                return true;
            }

            // Период полностью лежит в периоде нарушения
            crossRange = this;
            return true;
        }
开发者ID:Markeli,项目名称:BeardlyTeam,代码行数:30,代码来源:DateTimeRange.cs

示例4: TestSortedIntervalTree

        public void TestSortedIntervalTree()
        {
            DateTimeRange r0 = new DateTimeRange(baseDate, baseDate.AddHours(2));
            DateTimeRange r1 = new DateTimeRange(baseDate, baseDate.AddHours(4));
            DateTimeRange r2 = new DateTimeRange(baseDate, baseDate.AddHours(7));
            DateTimeRange r3 = new DateTimeRange(baseDate.AddHours(3), baseDate.AddHours(3));
            DateTimeRange r4 = new DateTimeRange(baseDate.AddHours(4), baseDate.AddHours(12));
            DateTimeRange r5 = new DateTimeRange(baseDate.AddHours(5), baseDate.AddHours(7));

            tree.Insert(r0, r0);
            tree.Insert(r1, r1);
            tree.Insert(r2, r2);
            tree.Insert(r3, r3);
            tree.Insert(r4, r4);
            tree.Insert(r5, r5);

            Assert.AreEqual(6, tree.NumNodes);
            Assert.AreEqual(5, tree.MaxDepth); // TODO

            DateTimeRange s0 = new DateTimeRange(baseDate.AddHours(1), baseDate.AddHours(1));
            List<DateTimeRange> result = tree.FindAll(s0);

            Assert.AreEqual(3, result.Count);
            Assert.AreEqual(r0, result[0]);
            Assert.AreEqual(r1, result[1]);
            Assert.AreEqual(r2, result[2]);
        }
开发者ID:pkdevboxy,项目名称:calendar-connectors,代码行数:27,代码来源:IntervalTreeTest.cs

示例5: LookupFreeBusyTimes

        /// <summary>
        /// Returns the free busy times for the specified exchange users
        /// </summary>
        /// <param name="users">The user which free/busy blocks will be looked up for</param>
        /// <param name="window">The time period to look up FB info for</param>
        /// <returns></returns>
        public Dictionary<ExchangeUser, FreeBusy> LookupFreeBusyTimes(
            ExchangeUserDict users,
            DateTimeRange window )
        {
            /* Create an array of mailboxes to retrieve from exchange */
            Dictionary<ExchangeUser, FreeBusy> result = new Dictionary<ExchangeUser, FreeBusy>();

            try
            {
                using (BlockTimer bt = new BlockTimer("LookupFreeBusyTimes"))
                {
                    /* Perform the retrieval of free busy times through WebDav */
                    result = webDavQuery.LoadFreeBusy(exchangeServerUrl, users, window);
                }
            }
            catch (Exception ex)
            {
                throw new GCalExchangeException(
                    GCalExchangeErrorCode.ExchangeUnreachable,
                   "Error occured while retrieving free busy ranges",
                   ex);
            }

            return result;
        }
开发者ID:pkdevboxy,项目名称:calendar-connectors,代码行数:31,代码来源:FreeBusyService.cs

示例6: EqualDifferentPrecisionHourMinuteTest

 public void EqualDifferentPrecisionHourMinuteTest()
 {
     var d1 = new DateTimeRange(new DateTime(2011, 4, 4, 10, 34, 10), DateTimeRange.PrecisionType.Minutes);
     var d2 = new DateTimeRange(new DateTime(2011, 4, 4, 10, 1, 4), DateTimeRange.PrecisionType.Hours);
     Assert.AreEqual(d1, d2);
     Assert.AreEqual(d2, d1);
 }
开发者ID:yash0924,项目名称:csharputils,代码行数:7,代码来源:DateTimeRangeTest.cs

示例7: GetPortraits

        public IList<Portrait> GetPortraits(int cameraId, DateTimeRange range)
        {
            var portraits = from f in System.IO.Directory.GetFiles(this._directoryPath, "*.jpg")
                            select new Portrait(f);

            return portraits.ToList();
        }
开发者ID:dalinhuang,项目名称:appcollection,代码行数:7,代码来源:DirectoryRepository.cs

示例8: GenerateResponse

        /// <summary>
        /// Generates a response from a GCalRequest
        /// </summary>
        /// <returns></returns>
        public string GenerateResponse()
        {
            /* Create a string builder to hold the text for the response */
            StringBuilder result = new StringBuilder(4096);

            /* Create an exchange provider */
            ExchangeService gateway = new ExchangeService(
                ConfigCache.ExchangeServerUrl,
                ConfigCache.ExchangeUserLogin,
                ConfigCache.ExchangeUserPassword);

            /* Return the exchangers from the GCal Request that was passed in */
            DateTimeRange range = new DateTimeRange(request.UTCStartDate, request.UTCEndDate);
            ExchangeUserDict exchangeUsers = gateway.SearchByEmail(range, request.ExchangeUsers);

            /* Create the header of the request */
            result.AppendFormat("['{0}','{1}',", request.VersionNumber, request.MessageId);

            result.AppendFormat("['_ME_AddData','{0}/{1}','{2}'",
                                DateUtil.FormatDateForGoogle(request.StartDate),
                                DateUtil.FormatDateForGoogle(request.EndDate),
                                DateUtil.FormatDateTimeForGoogle(request.Since));

            /* Flag for inserting commas */
            bool firstUser = true;

            result.Append(",[");

            foreach (ExchangeUser user in exchangeUsers.Values)
            {
                /* Don't add a comma if this is the first user */
                if (!firstUser)
                {
                    result.Append(",");
                }

                /* Add the user's credentials */
                string email = ConfigCache.MapToExternalDomain(user.Email);
                result.AppendFormat("'{0}','{1}','{2}',[",
                                    user.DisplayName,
                                    email,
                                    (int)user.AccessLevel);

                GenerateResponseForTimeBlocks(user,
                                              result);

                result.Append("]");
                firstUser = false;
            }

            result.Append("]");
            result.Append("]");
            result.Append("]");

            log.Info("GCal Free/Busy response successfully generated.");
            log.DebugFormat("Response = {0}", result);

            return result.ToString();
        }
开发者ID:pkdevboxy,项目名称:calendar-connectors,代码行数:63,代码来源:GCalFreeBusyResponse.cs

示例9: Appointment

        /// <summary>
        /// Initializes a new instance of the <see cref="Appointment"/> class.
        /// </summary>
        /// <param name="staff">The staff.</param>
        /// <param name="appointmentDateTimeRange">The appointment date time range.</param>
        protected internal Appointment( Staff staff, DateTimeRange appointmentDateTimeRange )
        {
            Check.IsNotNull ( staff, "Staff is required." );
            Check.IsNotNull ( appointmentDateTimeRange, "AppointmentDateTimeRange is required." );

            _staff = staff;
            _appointmentDateTimeRange = appointmentDateTimeRange;
        }
开发者ID:divyang4481,项目名称:REM,代码行数:13,代码来源:Appointment.cs

示例10: GetTodos

    public Task<IReadOnlyList<EntityIdWithVersion<Uri, string>>> GetTodos (DateTimeRange? range)
    {
      if (range != null)
        throw new NotSupportedException ("range not supported");

      return Task.FromResult<IReadOnlyList<EntityIdWithVersion<Uri, string>>> (
          _entites.Select (e => EntityIdWithVersion.Create (e.Key, e.Value.Item1)).ToList());
    }
开发者ID:rafaelriedel,项目名称:outlookcaldavsynchronizer,代码行数:8,代码来源:InMemoryCalDAVServer.cs

示例11: CreateAppointment

        /// <summary>
        /// Creates the appointment.
        /// </summary>
        /// <param name="staff">
        /// The staff.
        /// </param>
        /// <param name="appointmentDateTimeRange">
        /// The appointment date time range.
        /// </param>
        /// <returns>
        /// An Appointment.
        /// </returns>
        public Appointment CreateAppointment( Staff staff, DateTimeRange appointmentDateTimeRange )
        {
            var appointment = new Appointment ( staff, appointmentDateTimeRange );

            _appointmentRepository.MakePersistent ( appointment );

            return appointment;
        }
开发者ID:divyang4481,项目名称:REM,代码行数:20,代码来源:AppointmentFactory.cs

示例12: TestDateTimeRange

        public void TestDateTimeRange()
        {
            DateTimeRange range = new DateTimeRange(startDate, endDate);
            DateTimeRange compareRange = new DateTimeRange(startDate, endDate);

            Assert.AreEqual(startDate, range.Start);
            Assert.AreEqual(endDate, range.End);
            Assert.AreEqual(range, compareRange);
            Assert.AreEqual(range.GetHashCode(), compareRange.GetHashCode());
        }
开发者ID:pkdevboxy,项目名称:calendar-connectors,代码行数:10,代码来源:DateTimeRangeTest.cs

示例13: LoadVideo

        public void LoadVideo()
        {
            var selectedCamera = this._screen.SelectedCamera;
            if (selectedCamera == null)
            {
                return;
            }

            var range = this._screen.TimeRange;
            var type = this._screen.SearchScope;
            var frameQuery = _portraitRepository.GetFrames(selectedCamera.Id, range).ToArray();
            var portraitQuery = _portraitRepository.GetPortraits(selectedCamera.Id, range).ToArray();
            Core.Video v;
            this._screen.ClearAll();

            for (int i = currentPage * PageSize; i < currentPage * PageSize + PageSize; i++)
            {
                if (i >= TotalCount)
                {
                    break;
                }
                v = TotalVideos[i];
                var queryTime = new DateTimeRange(v.CapturedAt, v.CapturedAt);
                v.HasMotionDetected = frameQuery.FirstOrDefault(f => f.CapturedAt.RoundToMinute() == v.CapturedAt.RoundToMinute()) != null;
                v.HasFaceCaptured = portraitQuery.FirstOrDefault(p => p.CapturedAt.RoundToMinute() == v.CapturedAt.RoundToMinute()) != null;
                if ((type & SearchScope.FaceCapturedVideo)
                      == SearchScope.FaceCapturedVideo)
                {
                    if (v.HasFaceCaptured)
                    {
                        _screen.AddVideo(v);
                    }
                }

                if ((type & SearchScope.MotionWithoutFaceVideo)
                     == SearchScope.MotionWithoutFaceVideo)
                {
                    if (v.HasMotionDetected && !v.HasFaceCaptured)
                    {
                        _screen.AddVideo(v);
                    }
                }

                if ((type & SearchScope.MotionLessVideo)
                      == SearchScope.MotionLessVideo)
                {
                    if (!v.HasFaceCaptured && !v.HasMotionDetected)
                    {
                        _screen.AddVideo(v);
                    }
                }

            }
        }
开发者ID:dalinhuang,项目名称:appcollection,代码行数:54,代码来源:VideoQueryPresenterold.cs

示例14: DateTimeRangeTest_Ctor

        public void DateTimeRangeTest_Ctor()
        {
            DateTimeRange range = new DateTimeRange();
            Assert.AreEqual(range.StartTime, DateTime.MinValue);
            Assert.AreEqual(range.EndTime, DateTime.MaxValue);

            DateTime now = new DateTime(2015, 8, 7, 11, 15, 22);
            range = new DateTimeRange(now.Date.AddDays(-1), now.Date.AddDays(2));
            Assert.AreEqual(range.StartTime.Day, 6);
            Assert.AreEqual(range.EndTime.Day, 9);
        }
开发者ID:natoop,项目名称:osharp,代码行数:11,代码来源:DateTimeRangeTests.cs

示例15: CreateVisit

        /// <summary>
        /// Creates the visit.
        /// </summary>
        /// <param name="staff">The staff.</param>
        /// <param name="appointmentDateTimeRange">The appointment date time range.</param>
        /// <param name="clinicalCase">The clinical case.</param>
        /// <param name="visitTemplate">The visit template.</param>
        /// <param name="serviceLocation">The service location.</param>
        /// <returns>
        /// A Visit.
        /// </returns>
        public Visit CreateVisit(Staff staff, 
            DateTimeRange appointmentDateTimeRange,
            ClinicalCase clinicalCase,
            VisitTemplate visitTemplate,
            Location serviceLocation )
        {
            var visitStatus = _visitStatusRepository.GetByWellKnownName ( WellKnownNames.VisitModule.VisitStatus.Scheduled );
            var visit = new Visit (staff, appointmentDateTimeRange, clinicalCase, visitStatus, serviceLocation, visitTemplate.Name, visitTemplate.CptCode );

            _visitRepository.MakePersistent ( visit );
            return visit;
        }
开发者ID:divyang4481,项目名称:REM,代码行数:23,代码来源:VisitFactory.cs


注:本文中的DateTimeRange类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。