protected MonthTimeRange(int startYear, int startMonth, int monthCount, ITimeCalendar calendar) : base(GetPeriodOf(startYear, startMonth, monthCount), calendar) { monthCount.ShouldBePositive("monthCount"); MonthCount = monthCount; var yearAndMonth = TimeTool.AddMonth(startYear, startMonth, monthCount - 1); EndYear = yearAndMonth.Year ?? 0; EndMonth = yearAndMonth.Month ?? 1; }
private void panelBattle_MouseMove(object sender, MouseEventArgs e) { if (lastMouseMoveTime + 50 > TimeTool.GetNowMiliSecond()) { return; } lastMouseMoveTime = TimeTool.GetNowMiliSecond(); mouseX = e.X; mouseY = e.Y; }
public void PreviousHalfyearTest() { int year; YearHalfyear halfyear; TimeTool.PreviousHalfyear(YearHalfyear.First, out year, out halfyear); Assert.Equal(YearHalfyear.Second, halfyear); TimeTool.PreviousHalfyear(YearHalfyear.Second, out year, out halfyear); Assert.Equal(YearHalfyear.First, halfyear); } // PreviousHalfyearTest
public void NextHalfyearTest() { int year; YearHalfyear halfyear; TimeTool.NextHalfyear(YearHalfyear.First, out year, out halfyear); Assert.Equal(YearHalfyear.Second, halfyear); TimeTool.NextHalfyear(YearHalfyear.Second, out year, out halfyear); Assert.Equal(YearHalfyear.First, halfyear); } // NextHalfyearTest
public void AdjuestPeriodWithStartAndEnd() { var start = min; var end = max; TimeTool.AdjustPeriod(ref start, ref end); end.Should().Be.GreaterThan(start); TimeTool.AdjustPeriod(ref end, ref start); start.Should().Be.GreaterThan(end); }
public FilterDefinition <DbArkEntry <T> > GetPrimalContentFilter <T>(int?lastEpoch) { var filterBuilder = Builders <DbArkEntry <T> > .Filter; var filter = filterBuilder.Eq("package_name", name); if (lastEpoch.HasValue) { filter = filter & filterBuilder.Gt("time", TimeTool.GetTicksFromStandardEpoch(lastEpoch.Value)); } return(filter); }
public void IsSameHalfyearTest() { Assert.IsTrue(TimeTool.IsSameHalfyear(new DateTime(2000, 1, 1), new DateTime(2000, 6, 30))); Assert.IsTrue(TimeTool.IsSameHalfyear(new DateTime(2000, 7, 1), new DateTime(2000, 12, 31))); Assert.IsFalse(TimeTool.IsSameHalfyear(new DateTime(2000, 1, 1), new DateTime(2000, 7, 1))); Assert.IsFalse(TimeTool.IsSameHalfyear(new DateTime(2000, 7, 1), new DateTime(2001, 1, 1))); Assert.IsTrue(TimeTool.IsSameHalfyear(new DateTime(2000, 4, 1), new DateTime(2000, 9, 30), April)); Assert.IsTrue(TimeTool.IsSameHalfyear(new DateTime(2000, 10, 1), new DateTime(2001, 3, 31), April)); Assert.IsFalse(TimeTool.IsSameHalfyear(new DateTime(2000, 4, 1), new DateTime(2000, 10, 1), April)); Assert.IsFalse(TimeTool.IsSameHalfyear(new DateTime(2000, 10, 1), new DateTime(2001, 4, 1), April)); }
public void AddHalfyearTest() { int year; YearHalfyear halfyear; TimeTool.AddHalfyear(YearHalfyear.First, 1, out year, out halfyear); Assert.Equal(YearHalfyear.Second, halfyear); TimeTool.AddHalfyear(YearHalfyear.First, -1, out year, out halfyear); Assert.Equal(YearHalfyear.Second, halfyear); TimeTool.AddHalfyear(YearHalfyear.Second, 1, out year, out halfyear); Assert.Equal(YearHalfyear.First, halfyear); TimeTool.AddHalfyear(YearHalfyear.Second, -1, out year, out halfyear); Assert.Equal(YearHalfyear.First, halfyear); TimeTool.AddHalfyear(YearHalfyear.First, 2, out year, out halfyear); Assert.Equal(YearHalfyear.First, halfyear); TimeTool.AddHalfyear(YearHalfyear.First, -2, out year, out halfyear); Assert.Equal(YearHalfyear.First, halfyear); TimeTool.AddHalfyear(YearHalfyear.Second, 2, out year, out halfyear); Assert.Equal(YearHalfyear.Second, halfyear); TimeTool.AddHalfyear(YearHalfyear.Second, -2, out year, out halfyear); Assert.Equal(YearHalfyear.Second, halfyear); TimeTool.AddHalfyear(YearHalfyear.First, 5, out year, out halfyear); Assert.Equal(YearHalfyear.Second, halfyear); TimeTool.AddHalfyear(YearHalfyear.First, -5, out year, out halfyear); Assert.Equal(YearHalfyear.Second, halfyear); TimeTool.AddHalfyear(YearHalfyear.Second, 5, out year, out halfyear); Assert.Equal(YearHalfyear.First, halfyear); TimeTool.AddHalfyear(YearHalfyear.Second, -5, out year, out halfyear); Assert.Equal(YearHalfyear.First, halfyear); TimeTool.AddHalfyear(2008, YearHalfyear.First, 1, out year, out halfyear); Assert.Equal(2008, year); Assert.Equal(YearHalfyear.Second, halfyear); TimeTool.AddHalfyear(2008, YearHalfyear.Second, 1, out year, out halfyear); Assert.Equal(2009, year); Assert.Equal(YearHalfyear.First, halfyear); TimeTool.AddHalfyear(2008, YearHalfyear.First, 2, out year, out halfyear); Assert.Equal(2009, year); Assert.Equal(YearHalfyear.First, halfyear); TimeTool.AddHalfyear(2008, YearHalfyear.Second, 2, out year, out halfyear); Assert.Equal(2009, year); Assert.Equal(YearHalfyear.Second, halfyear); TimeTool.AddHalfyear(2008, YearHalfyear.First, 3, out year, out halfyear); Assert.Equal(2009, year); Assert.Equal(YearHalfyear.Second, halfyear); TimeTool.AddHalfyear(2008, YearHalfyear.Second, 3, out year, out halfyear); Assert.Equal(2010, year); Assert.Equal(YearHalfyear.First, halfyear); } // AddHalfyearTest
public void TrimSecondTest() { TimeTool.TrimToSecond(testTime).Should().Be(testTime.Date.AddHours(testTime.Hour).AddMinutes(testTime.Minute)); Enumerable .Range(0, TimeSpec.SecondsPerMinute) .RunEach( s => { TimeTool.TrimToSecond(testTime, s).Should().Be( testTime.Date.AddHours(testTime.Hour).AddMinutes(testTime.Minute).AddSeconds(s)); }); }
public void HasTimeOfDayTest() { TimeTool.HasTimePart(testTime).Should().Be.True(); TimeTool.HasTimePart(nowTime).Should().Be.True(); TimeTool.HasTimePart(nowTime.SetTimePart(1)).Should().Be.True(); TimeTool.HasTimePart(nowTime.SetTimePart(0, 1)).Should().Be.True(); TimeTool.HasTimePart(nowTime.SetTimePart(0, 0, 1)).Should().Be.True(); TimeTool.HasTimePart(nowTime.SetTimePart(0, 0, 0, 1)).Should().Be.True(); TimeTool.HasTimePart(nowTime.SetTimePart(0, 0, 0, 0)).Should().Be.False(); }
public void OnLogin() { if (TimeManager.IsDifferDay(InfoBasic.LastLoginTime, TimeTool.DateTimeToUnixTime(DateTime.Now))) { OnNewDay(); } InfoBasic.LastLoginTime = TimeTool.DateTimeToUnixTime(DateTime.Now); foreach (var userInfoSub in itemSubList) { userInfoSub.OnLogin(); } }
public static void AddImage(string path, Image img, bool isPersist = false) { ImageItem item = new ImageItem { Image = img, Time = TimeTool.DateTimeToUnixTime(DateTime.Now), Persist = isPersist }; images[path] = item; count++; }
public void AddHalfyearTest() { int year; YearHalfyear halfyear; TimeTool.AddHalfyear(YearHalfyear.First, 1, out year, out halfyear); Assert.AreEqual(halfyear, YearHalfyear.Second); TimeTool.AddHalfyear(YearHalfyear.First, -1, out year, out halfyear); Assert.AreEqual(halfyear, YearHalfyear.Second); TimeTool.AddHalfyear(YearHalfyear.Second, 1, out year, out halfyear); Assert.AreEqual(halfyear, YearHalfyear.First); TimeTool.AddHalfyear(YearHalfyear.Second, -1, out year, out halfyear); Assert.AreEqual(halfyear, YearHalfyear.First); TimeTool.AddHalfyear(YearHalfyear.First, 2, out year, out halfyear); Assert.AreEqual(halfyear, YearHalfyear.First); TimeTool.AddHalfyear(YearHalfyear.First, -2, out year, out halfyear); Assert.AreEqual(halfyear, YearHalfyear.First); TimeTool.AddHalfyear(YearHalfyear.Second, 2, out year, out halfyear); Assert.AreEqual(halfyear, YearHalfyear.Second); TimeTool.AddHalfyear(YearHalfyear.Second, -2, out year, out halfyear); Assert.AreEqual(halfyear, YearHalfyear.Second); TimeTool.AddHalfyear(YearHalfyear.First, 5, out year, out halfyear); Assert.AreEqual(halfyear, YearHalfyear.Second); TimeTool.AddHalfyear(YearHalfyear.First, -5, out year, out halfyear); Assert.AreEqual(halfyear, YearHalfyear.Second); TimeTool.AddHalfyear(YearHalfyear.Second, 5, out year, out halfyear); Assert.AreEqual(halfyear, YearHalfyear.First); TimeTool.AddHalfyear(YearHalfyear.Second, -5, out year, out halfyear); Assert.AreEqual(halfyear, YearHalfyear.First); TimeTool.AddHalfyear(2008, YearHalfyear.First, 1, out year, out halfyear); Assert.AreEqual(year, 2008); Assert.AreEqual(halfyear, YearHalfyear.Second); TimeTool.AddHalfyear(2008, YearHalfyear.Second, 1, out year, out halfyear); Assert.AreEqual(year, 2009); Assert.AreEqual(halfyear, YearHalfyear.First); TimeTool.AddHalfyear(2008, YearHalfyear.First, 2, out year, out halfyear); Assert.AreEqual(year, 2009); Assert.AreEqual(halfyear, YearHalfyear.First); TimeTool.AddHalfyear(2008, YearHalfyear.Second, 2, out year, out halfyear); Assert.AreEqual(year, 2009); Assert.AreEqual(halfyear, YearHalfyear.Second); TimeTool.AddHalfyear(2008, YearHalfyear.First, 3, out year, out halfyear); Assert.AreEqual(year, 2009); Assert.AreEqual(halfyear, YearHalfyear.Second); TimeTool.AddHalfyear(2008, YearHalfyear.Second, 3, out year, out halfyear); Assert.AreEqual(year, 2010); Assert.AreEqual(halfyear, YearHalfyear.First); } // AddHalfyearTest
public void ForEachPeriodsTest(PeriodKind periodKind) { var count = 0; var period = GetPeriod(); if (period.HasPeriod) { var periods = TimeTool.ForEachPeriods(period, periodKind).Take(1000); periods.RunEach(item => { count++; }); Assert.AreEqual(periods.Count(), count); } }
public void ForEachMinutesTest() { var count = 0; var period = GetPeriod(); if (period.HasPeriod) { var minutes = TimeTool.ForEachMinutes(period).Take(100); minutes.RunEach(m => count++); Assert.AreEqual(minutes.Count(), count); } }
private void MainForm_MouseMove(object sender, MouseEventArgs e) { if (lastMouseMoveTime + 50 > TimeTool.GetNowMiliSecond()) { return; } lastMouseMoveTime = TimeTool.GetNowMiliSecond(); if (SystemMenuManager.UpdateToolbar(e.X, e.Y)) { tabPageGame.Invalidate(); } }
public void Update() { if (isDirty) { var ntl = TimeTool.DateTimeToUnixTimeDouble(DateTime.Now); if (ntl >= lastActTime + interval) { step(); lastActTime = ntl; isDirty = false; } } }
/// <summary> /// 주 단위의 기간에 포함된 Day의 컬렉션을 반환합니다. /// </summary> /// <returns></returns> public IEnumerable <DayRange> GetDays() { var startDay = TimeTool.GetStartOfYearWeek(Year, StartWeek, TimeCalendar.Culture, TimeCalendar.WeekOfYearRule); var dayCount = WeekCount * TimeSpec.DaysPerWeek; return (Enumerable.Range(0, dayCount) #if !SILVERLIGHT .AsParallel() .AsOrdered() #endif .Select(d => new DayRange(startDay.AddDays(d), TimeCalendar))); }
protected HalfyearTimeRange(int startYear, HalfyearKind startHalfyearKind, int halfyearCount, ITimeCalendar calendar) : base(GetPeriodOf(calendar.YearBaseMonth, startYear, startHalfyearKind, halfyearCount), calendar) { StartYear = startYear; StartHalfyear = startHalfyearKind; HalfyearCount = halfyearCount; var endYearAndHalfyear = TimeTool.AddHalfyear(startHalfyearKind, startYear, halfyearCount - 1); EndYear = endYearAndHalfyear.Year ?? StartYear; EndHalfyear = endYearAndHalfyear.Halfyear ?? StartHalfyear; }
//记录销售信息 public static async void RecordMarketInfo(this AgencyComponent agencyComponent, long sellerUserId, User buyerUser, int jewelNum) { MarketInfo marketInfo = ComponentFactory.Create <MarketInfo>(); marketInfo.SellUserId = sellerUserId; marketInfo.MaiJiaUserId = buyerUser.UserId; marketInfo.MaiJiaName = buyerUser.Name; marketInfo.JewelNum = jewelNum; marketInfo.Time = TimeTool.GetCurrenTimeStamp(); await agencyComponent.dbProxyComponent.Save(marketInfo); marketInfo.Dispose(); }
public static TopUpRecord Create(string orderId, long userId, Commodity commodity) { TopUpRecord topUpRecord = ComponentFactory.Create <TopUpRecord>(); topUpRecord.OrderId = orderId; topUpRecord.TopUpUserId = userId; topUpRecord.Money = commodity.Price; topUpRecord.GoodsId = commodity.CommodityType; topUpRecord.GoodsAmount = commodity.Amount; topUpRecord.TopUpState = TopUpStateType.NoPay; topUpRecord.Time = TimeTool.GetCurrenTimeStamp(); return(topUpRecord); }
protected QuarterTimeRange(int startYear, QuarterKind startQuarter, int quarterCount, ITimeCalendar calendar) : base(GetPeriodOf(calendar, startYear, startQuarter.GetHashCode(), quarterCount), calendar) { StartYear = startYear; StartQuarter = startQuarter; QuarterCount = quarterCount; var endYearQuarter = TimeTool.AddQuarter(startQuarter, startYear, quarterCount - 1); EndYear = endYearQuarter.Year ?? StartYear; EndQuarter = endYearQuarter.Quarter ?? StartQuarter; }
public void ForEachHoursTest() { var count = 0; var period = GetPeriod(); if (period.HasPeriod) { var hours = TimeTool.ForEachHours(period).Take(100); hours.RunEach(hour => count++); Assert.AreEqual(hours.Count(), count); } }
public void InitPanel() { if (mData.IsStopSeal) { mTypeText.text = "封号"; } else { mTypeText.text = "解封"; } mTimeText.text = TimeTool.ConvertLongToTimeDesc(mData.Time); mRemarkText.text = mData.Explain; }
public override async void Awake(GameLobby self) { long nextModayGapStamp = TimeTool.GetNextModayGapTimeStamp(); await Game.Scene.GetComponent <TimerComponent>().WaitAsync(TimeTool.TicksConvertMillisecond(nextModayGapStamp)); Session friendsSession = Game.Scene.GetComponent <NetInnerSessionComponent>().Get(AppType.FriendsCircle);//获取亲友圈 Session while (true) { self.WeekRefreshAction?.Invoke(); //调用整点刷新 friendsSession.Send(new L2S_WeekRefresh()); //现在 每周刷新 只有亲友圈服务需要 await Game.Scene.GetComponent <TimerComponent>().WaitAsync(TimeTool.TicksConvertMillisecond(TimeTool.WeekTime)); } }
public bool UseSeed(int type, int dura) { for (int i = 0; i < 9; i++) { var targetCell = DbFarmState[i]; if (targetCell.Type == 0) { targetCell.Type = type; targetCell.Time = TimeTool.DateTimeToUnixTime(DateTime.Now) + dura; return(true); } } return(false); }
public void RunPeriodTest(PeriodKind periodKind) { var period = GetPeriod(); if (period.HasPeriod) { var periods = TimeTool.ForEachPeriods(period, periodKind).Take(1000); var count = 0; var max = TimeTool.RunPeriod(period, periodKind, p => ++ count).Take(1000).Last(); Assert.AreEqual(periods.Count(), max); } }
public void PreviousQuarterTest() { int year; YearQuarter quarter; TimeTool.PreviousQuarter(YearQuarter.First, out year, out quarter); Assert.Equal(YearQuarter.Fourth, quarter); TimeTool.PreviousQuarter(YearQuarter.Second, out year, out quarter); Assert.Equal(YearQuarter.First, quarter); TimeTool.PreviousQuarter(YearQuarter.Third, out year, out quarter); Assert.Equal(YearQuarter.Second, quarter); TimeTool.PreviousQuarter(YearQuarter.Fourth, out year, out quarter); Assert.Equal(YearQuarter.Third, quarter); } // PreviousQuarterTest
public void TrimMilliSecondTest() { TimeTool.TrimToMillisecond(testTime).Should().Be( testTime.Date.AddHours(testTime.Hour).AddMinutes(testTime.Minute).AddSeconds(testTime.Second)); Enumerable .Range(0, TimeSpec.MillisecondsPerSecond) .RunEach(ms => { var trimToMS = testTime.Date.AddHours(testTime.Hour).AddMinutes(testTime.Minute).AddSeconds(testTime.Second). AddMilliseconds(ms); TimeTool.TrimToMillisecond(testTime, ms).Should().Be(trimToMS); }); }
public void NextQarterTest() { int year; YearQuarter quarter; TimeTool.NextQuarter(YearQuarter.First, out year, out quarter); Assert.AreEqual(quarter, YearQuarter.Second); TimeTool.NextQuarter(YearQuarter.Second, out year, out quarter); Assert.AreEqual(quarter, YearQuarter.Third); TimeTool.NextQuarter(YearQuarter.Third, out year, out quarter); Assert.AreEqual(quarter, YearQuarter.Fourth); TimeTool.NextQuarter(YearQuarter.Fourth, out year, out quarter); Assert.AreEqual(quarter, YearQuarter.First); } // NextQarterTest