예제 #1
0
        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;
        }
예제 #2
0
        private void panelBattle_MouseMove(object sender, MouseEventArgs e)
        {
            if (lastMouseMoveTime + 50 > TimeTool.GetNowMiliSecond())
            {
                return;
            }
            lastMouseMoveTime = TimeTool.GetNowMiliSecond();

            mouseX = e.X;
            mouseY = e.Y;
        }
예제 #3
0
        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
예제 #4
0
        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
예제 #5
0
        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);
        }
예제 #6
0
        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));
        }
예제 #8
0
        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
예제 #9
0
        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();
        }
예제 #11
0
 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();
     }
 }
예제 #12
0
        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++;
        }
예제 #13
0
        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
예제 #14
0
        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);
            }
        }
예제 #15
0
        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);
            }
        }
예제 #16
0
        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();
            }
        }
예제 #17
0
 public void Update()
 {
     if (isDirty)
     {
         var ntl = TimeTool.DateTimeToUnixTimeDouble(DateTime.Now);
         if (ntl >= lastActTime + interval)
         {
             step();
             lastActTime = ntl;
             isDirty     = false;
         }
     }
 }
예제 #18
0
        /// <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)));
        }
예제 #19
0
        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;
        }
예제 #20
0
        //记录销售信息
        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();
        }
예제 #21
0
        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);
        }
예제 #22
0
        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;
        }
예제 #23
0
        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);
            }
        }
예제 #24
0
 public void InitPanel()
 {
     if (mData.IsStopSeal)
     {
         mTypeText.text = "封号";
     }
     else
     {
         mTypeText.text = "解封";
     }
     mTimeText.text   = TimeTool.ConvertLongToTimeDesc(mData.Time);
     mRemarkText.text = mData.Explain;
 }
예제 #25
0
        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));
            }
        }
예제 #26
0
 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);
 }
예제 #27
0
        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);
            }
        }
예제 #28
0
        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
예제 #29
0
        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);
            });
        }
예제 #30
0
        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