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


C# DateTime.AddMinutes方法代码示例

本文整理汇总了C#中System.DateTime.AddMinutes方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.AddMinutes方法的具体用法?C# DateTime.AddMinutes怎么用?C# DateTime.AddMinutes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.DateTime的用法示例。


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

示例1: Next

        public override DateTime Next(DateTime time, out bool changed)
        {
            changed = false;

            if (Values.Count < 1)
            {
                return time;
            }
            if (Type == CGtd.DATES_TYPE_EACH)
            {
                return time.AddMinutes(Values[0]);
            }
            if (Type == CGtd.DATES_TYPE_WHEN)
            {
                int idx = time.Minute;
                int tmp = NextValue(idx, changed);
                if (tmp > 0)
                {
                    return time.AddMinutes(tmp);
                }
                if (tmp < 0)
                {
                    changed = true;
                    return time.AddHours(1).AddMinutes(Values[0] - idx);
                }
            }
            return time;
        }
开发者ID:burstas,项目名称:rmps,代码行数:28,代码来源:Minute.cs

示例2: LoadLocationWeatherData

        public static WeatherLocatioinModel LoadLocationWeatherData(DateTime now, Location location, WeatherData[] locationData)
        {
            var minDate = now.AddMinutes(-90);
            var maxDate = now.AddMinutes(90);

            // погода на текущее время
            var current = locationData.FirstOrDefault(d => d.Date > minDate && d.Date <= maxDate);

            // погода на ближайшие сутки
            var xxx = current != null ? current.Date : now;
            var day = locationData
                        .Where(d => d.Date > xxx && d.Date <= xxx.AddDays(1))
                        .Where(FilterByHours)
                        .OrderBy(d => d.Date)
                        .Take(3)
                        .ToArray();

            // прогноз на несколько дней
            var forecast = locationData
                        .Where(d => d.Date.Date > now.Date)
                        .GroupBy(d => d.Date.Date)
                        .Take(3);

            return new WeatherLocatioinModel
            {
                LocationId = location.Id,
                LocationName = location.DisplayName,
                Now = CreateNowModel(current),
                Today = day.Select(CreateNowModel).ToArray(),
                Forecast = forecast.Select(CreateDayModel).ToArray()
            };
        }
开发者ID:KonstantinKolesnik,项目名称:SmartHub,代码行数:32,代码来源:ModelBuilder.cs

示例3: CompareDate

        public static bool CompareDate(DateTime dateToCompare, DateTime date, int minuteTolerance)
        {
            if (!dateToCompare.Equals(date))
            {
                date = date.AddMinutes(minuteTolerance);

                if (!dateToCompare.Equals(date))
                {
                    date = date.AddMinutes(-2 * minuteTolerance);

                    if (!dateToCompare.Equals(date))
                    {
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }
                else
                {
                    return true;
                }
            }
            else
            {
                return true;
            }
        }
开发者ID:skiel85,项目名称:taller-desarrollo-proyectos-i,代码行数:29,代码来源:DateTimeComparer.cs

示例4: GetStudentClassList

        /// <summary>
        /// 作者:Beta 
        /// 时间:2014.03.17
        /// 描述:获取样式列表(需求展示)
        /// </summary>
        /// <param name="list"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static string GetStudentClassList(List<Model.Eme.BookRequirement> list, DateTime dt)
        {
            var classlist = " select-item";

            if (dt.AddHours(-1) < DateTime.Now)
            {
                if (list.Any(p => p.BookStartTime <= dt && p.BookEndTime >= dt.AddMinutes(30) && p.IsSuccessful))
                {
                    classlist = classlist + " successful";
                }
                else if (list.Any(p => p.BookStartTime <= dt && p.BookEndTime >= dt.AddMinutes(30) && !p.IsSuccessful))
                {
                    classlist = classlist + " pass";
                }
                else
                {
                    classlist = classlist + " unavailable";
                }
            }
            else
            {
                if (list.Any(p => p.BookStartTime <= dt && p.BookEndTime >= dt.AddMinutes(30) && p.IsSuccessful))
                {
                    classlist = classlist + " successful";
                }
                else if (list.Any(p => p.BookStartTime <= dt && p.BookEndTime >= dt.AddMinutes(30) && !p.IsSuccessful))
                {
                    classlist = classlist + " normal oking";
                }
            }
            return classlist;
        }
开发者ID:kylin589,项目名称:EmePro,代码行数:40,代码来源:BookRequirementController.cs

示例5: GetNext30Minute

        /// <summary>
        /// Returns the date that is 30 minutes before or after input date if input date minute is 0 or 30. Otherwise it returns next increment to 0 or 30.
        /// </summary>
        /// <param name="date">Date and time.</param>
        /// <param name="forward">Indicates whether to add or subtract minutes.</param>
        /// <returns>New date time.</returns>
        public static DateTime GetNext30Minute(DateTime date, bool forward)
        {
            if (date.Minute == 0 || date.Minute == 30)
                return (date.AddMinutes(forward ? 30 : -30));

            return (date.AddMinutes((forward ? 1 : -1) * Math.Abs(30 - date.Minute)));
        }
开发者ID:huamanhtuyen,项目名称:VNACCS,代码行数:13,代码来源:DateHelper.cs

示例6: UpdatesAfterCorrectPeriodElapses

        public void UpdatesAfterCorrectPeriodElapses()
        {
            const int periods = 3;
            var periodSpan = Time.OneMinute;
            var reference = new DateTime(2016, 04, 06, 12, 0, 0);
            var referenceUtc = reference.ConvertToUtc(TimeZones.NewYork);
            var timeKeeper = new TimeKeeper(referenceUtc);
            var config = new SubscriptionDataConfig(typeof (TradeBar), Symbols.SPY, Resolution.Minute, TimeZones.NewYork, TimeZones.NewYork, true, false, false);
            var security = new Security(SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork), config, new Cash("USD", 0, 0), SymbolProperties.GetDefault("USD"));
            security.SetLocalTimeKeeper(timeKeeper.GetLocalTimeKeeper(TimeZones.NewYork));

            var model = new RelativeStandardDeviationVolatilityModel(periodSpan, periods);
            security.VolatilityModel = model;

            var first = new IndicatorDataPoint(reference, 1);
            security.SetMarketPrice(first);

            Assert.AreEqual(0m, model.Volatility);

            const decimal value = 0.471404520791032M; // std of 1,2 is ~0.707 over a mean of 1.5
            var second = new IndicatorDataPoint(reference.AddMinutes(1), 2);
            security.SetMarketPrice(second);
            Assert.AreEqual(value, model.Volatility);

            // update should not be applied since not enough time has passed
            var third = new IndicatorDataPoint(reference.AddMinutes(1.01), 1000);
            security.SetMarketPrice(third);
            Assert.AreEqual(value, model.Volatility);

            var fourth = new IndicatorDataPoint(reference.AddMinutes(2), 3m);
            security.SetMarketPrice(fourth);
            Assert.AreEqual(0.5m, model.Volatility);
        }
开发者ID:kaffeebrauer,项目名称:Lean,代码行数:33,代码来源:RelativeStandardDeviationVolatilityModelTests.cs

示例7: areTeamsFree

 // Validates to check if teams in a match are available for a given time
 public bool areTeamsFree(Match m, DateTime startTime)
 {
     // Start time can not be earlier than the tournament stage start time
     if (m.TournamentStage.TimeInterval.StartTime > startTime)
     {
         return false;
     }
     foreach (Team team in m.Teams)
     {
         // Get the time interval for a team and for the parameter date
         TimeInterval timesForDate = team.TimeIntervals.First(x => x.StartTime.Date == startTime.Date);
         // Start time can not be earlier than teams start time and the match can not end later than a teams end time
         if (startTime < timesForDate.StartTime || startTime.AddMinutes(m.Duration) > timesForDate.EndTime)
         {
             return false;
         }
         // Check all the matches for the team
         foreach (Match match in team.Matches)
         {
             if (match.IsScheduled && startTime.AddMinutes(m.Duration * 2) > match.StartTime)
             {
                 DateTime teamBreakDone = match.StartTime.AddMinutes(match.Duration * 2);
                 if (startTime < teamBreakDone)
                 {
                     return false;
                 }
             }
         }
     }
     return true;
 }
开发者ID:Haurum,项目名称:P3,代码行数:32,代码来源:Validator.cs

示例8: ReorganizeAdStacks

 public void ReorganizeAdStacks(IDictionary<DateTime,  IDictionary<Guid, IDictionary<Ad, IDictionary<int, long>>>> adDispatchPlans, DateTime currentTime)
 {
     var time = new DateTime(currentTime.Year, currentTime.Month, currentTime.Day, currentTime.Hour, currentTime.Minute, 0);
     if (adDispatchPlans != null && adDispatchPlans.ContainsKey(time.AddMinutes(-1)) && adDispatchPlans.ContainsKey(time.AddMinutes(1)))
     {
         //上一分钟
         var lastMeidaAdPlans = adDispatchPlans[time.AddMinutes(-1)];
         //下一分钟
         var nextMediaAdPlans = adDispatchPlans[time.AddMinutes(1)];
         //轮询处理每个媒体的广告
         foreach (var lastAdMediaAdPlan in lastMeidaAdPlans.AsParallel())
         {
             var mediaId = lastAdMediaAdPlan.Key;
             if (!nextMediaAdPlans.ContainsKey(mediaId))
             {
                 nextMediaAdPlans[mediaId] = new ConcurrentDictionary<Ad, IDictionary<int, long>>();
             }
             //轮询处理该媒体内每个广告
             foreach (var lastAdPlan in lastAdMediaAdPlan.Value)
             {
                 int i = 0;
                 while (lastAdPlan.Value.ContainsKey(i))
                 {
                     if (!nextMediaAdPlans[mediaId].ContainsKey(lastAdPlan.Key))
                     {
                         nextMediaAdPlans[mediaId][lastAdPlan.Key] = new ConcurrentDictionary<int, long>();
                     }
                     //TODO:对于贴片位置定向的情况需要进行处理
                     nextMediaAdPlans[mediaId][lastAdPlan.Key][i + 1] = lastAdPlan.Value[i];
                     i++;
                 }
             }
         }
     }
 }
开发者ID:youprofit,项目名称:Lorn.ADSP,代码行数:35,代码来源:CommonAdStacksReorganizer.cs

示例9: InsertObjectBlock

        private void InsertObjectBlock()
        {
            _taskExecution1 = _executionHelper.InsertOverrideTaskExecution(_taskDefinitionId);

            _baseDateTime = new DateTime(2016, 1, 1);
            var block1 = _blocksHelper.InsertObjectBlock(_taskDefinitionId, DateTime.UtcNow, Guid.NewGuid().ToString()).ToString();
            _blockExecutionId = _blocksHelper.InsertBlockExecution(_taskExecution1, long.Parse(block1), _baseDateTime.AddMinutes(-20), _baseDateTime.AddMinutes(-20), _baseDateTime.AddMinutes(-25), BlockExecutionStatus.Started);
        }
开发者ID:Vanlightly,项目名称:Taskling.NET,代码行数:8,代码来源:When_ChangeStatus.cs

示例10: CalcNearestFiveMinTime

		public DateTime CalcNearestFiveMinTime(DateTime dateIn) {
			dateIn = dateIn.AddMinutes(-2);
			int iMin = 5 * (dateIn.Minute / 5);

			DateTime dateOut = dateIn.AddMinutes(0 - dateIn.Minute).AddMinutes(iMin);

			return dateOut;
		}
开发者ID:tridipkolkata,项目名称:CarrotCakeCMS,代码行数:8,代码来源:AdminBasePage.cs

示例11: GetDateRangesAllDescendingEndTimes

        private static IEnumerable<Interval<DateTime>> GetDateRangesAllDescendingEndTimes(DateTime date, int count)
        {
            var dateRanges = new Interval<DateTime>[count];

            for (int i = 1; i <= count; i++)
            {
                dateRanges[i - 1] = new Interval<DateTime>(date.AddMinutes(-i), date.AddMinutes(i));
            }

            return new List<Interval<DateTime>>(dateRanges).OrderBy(x => x.Min.Value);
        }
开发者ID:eried,项目名称:Orcomp,代码行数:11,代码来源:DateIntervalContainerTestBase.Benchmark.cs

示例12: Fill

        /// <summary>
        /// 填充没有统计到的时间点
        /// </summary>
        /// <param name="originalDataList"></param>
        /// <returns></returns>
        public IEnumerable<ServiceHostStatMinute> Fill(DateTime startDate, IEnumerable<ServiceHostStatMinute> originalDataList)
        {
            startDate = DateTime.Parse(startDate.ToString("yyyy-MM-dd HH:mm:00"));

            var filledDataList = new List<ServiceHostStatMinute>();
            for (var i = 2; i <= 31; i++)
            {
                var item = originalDataList.FirstOrDefault(m => m.StatTime == startDate.AddMinutes(i * -1)) ?? new ServiceHostStatMinute() { StatTime = startDate.AddMinutes(i * -1) };
                filledDataList.Add(item);
            }
            return filledDataList;
        }
开发者ID:hahalixiaojing,项目名称:easy.monitor,代码行数:17,代码来源:StatDataFillService.cs

示例13: InsertBreak

		public static long InsertBreak(long emp,DateTime start,int minutes) {
			ClockEvent ce=new ClockEvent();
			ce.ClockStatus=TimeClockStatus.Break;
			ce.EmployeeNum=emp;
			ce.TimeDisplayed1=start;
			ce.TimeEntered1=start;
			ce.TimeDisplayed2=start.AddMinutes(minutes);
			ce.TimeEntered2=start.AddMinutes(minutes);
			ce.ClockEventNum = ClockEvents.Insert(ce);
			ClockEvents.Update(ce);//Updates TimeDisplayed1 because it defaults to now().
			return ce.ClockEventNum;
		}
开发者ID:mnisl,项目名称:OD,代码行数:12,代码来源:ClockEventT.cs

示例14: AssertDateTimes

        /// <summary>
        /// Asserts that the dates are valid.
        /// </summary>
        public void AssertDateTimes(DateTime expectedDate, DateTime actualDate, int maxMinutesVariance = 1, string message = "")
        {
            if (expectedDate.AddMinutes(maxMinutesVariance) < actualDate)
              {
            Assert.Fail(message);
              }

              if (actualDate < expectedDate.AddMinutes(-maxMinutesVariance))
              {
            Assert.Fail(message);
              }
        }
开发者ID:mnoreke,项目名称:MNorekePublic,代码行数:15,代码来源:BaseWebApiTest.cs

示例15: InProcSessionCacheFixture

    public InProcSessionCacheFixture() {
      _nowUtc = new DateTime(2015, 10, 20, 21, 36, 14, DateTimeKind.Utc);
      _fakeSystemClock = A.Fake<ISystemClock>();
      ConfigureSystemClock_ToReturn(_nowUtc);

      _inProcSessionCache = new InProcSessionCache(_fakeSystemClock);
      _expiredSession = new InProcSession(new SessionId(Guid.NewGuid(), false), A.Dummy<ISession>(), _nowUtc.AddMinutes(-20), TimeSpan.FromMinutes(15));
      _activeSession = new InProcSession(new SessionId(Guid.NewGuid(), false), A.Dummy<ISession>(), _nowUtc.AddMinutes(-3), TimeSpan.FromMinutes(15));
      _inProcSessionCache.Set(_expiredSession);
      _inProcSessionCache.Set(_activeSession);
      _numberOfSessions = 2;
    }
开发者ID:DavidLievrouw,项目名称:Nancy.Session.InProc,代码行数:12,代码来源:InProcSessionCacheFixture.cs


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