예제 #1
0
        public long GetElapsedTime(ETimeType type = TIME_MILLISECOND)
        {
            long gap = Timer.ElapsedTicks;

            switch (type)
            {
            case TIME_100NANOSECOND:
                break;

            case TIME_MICROSECOND:
                gap /= 10;
                break;

            case TIME_MILLISECOND:
                gap = Timer.ElapsedMilliseconds;
                break;

            case TIME_SECOND:
                gap = Timer.ElapsedMilliseconds / (1000);
                break;

            case TIME_MINUTE:
                gap = Timer.ElapsedMilliseconds / (1000 * 60);
                break;

            case TIME_HOUR:
                gap = Timer.ElapsedMilliseconds / (1000 * 60 * 60);
                break;
            }
            return(gap);
        }
예제 #2
0
 public Competences(string competenceName, int competenceExperienceTime, ETimeType timeType, Guid idUser)
 {
     CompetenceName           = competenceName;
     CompetenceExperienceTime = competenceExperienceTime;
     TimeType = timeType;
     IdUser   = idUser;
 }
예제 #3
0
    public void OnAddClock()
    {
        ETimeType type = (ETimeType)Enum.Parse(typeof(ETimeType), _TimeTypes[_Drop.value]);

        if (type == ETimeType.Weekly)
        {
            ClockDataWeekly w = new ClockDataWeekly();
            w._Type = type;
            int hour;
            int minute;
            int date;
            if (!int.TryParse(_HourInput.text, out hour) || !int.TryParse(_MinuteInput.text, out minute) || !int.TryParse(_DateInput.text, out date))
            {
                date   = 1;
                hour   = 12;
                minute = 0;
            }
            w._DayOfWeek = date;
            w._Time      = (hour << 8) | minute;
            w._AudioPath = TimeManager.instance._CurClipPath;
            w._Name      = _NameInput.text;
            TimeManager.instance.AddClock(w);
        }
        UIManager.Instance.Close(this);
    }
예제 #4
0
        public bool MoreThan(long CompareTime, ETimeType type = TIME_MILLISECOND)
        {
            long gap = GetElapsedTime(type);

            if (gap > CompareTime)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
        public bool LessThan(double CompareTime, ETimeType type = TIME_MILLISECOND)
        {
            CompareTime = (long)CompareTime;
            long gap = GetElapsedTime(type);

            if (gap < CompareTime)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #6
0
        /// <summary>
        /// 获取开始时间
        /// </summary>
        /// <param name="TimeType">Week、Month、Season、Year</param>
        /// <param name="now"></param>
        /// <returns></returns>
        public static DateTime?GetTimeStartByType(ETimeType TimeType, DateTime now)
        {
            switch (TimeType)
            {
            case ETimeType.Week:
                return(now.AddDays(-(int)now.DayOfWeek + 1));

            case ETimeType.Month:
                return(now.AddDays(-now.Day + 1));

            case ETimeType.Season:
                var time = now.AddMonths(0 - ((now.Month - 1) % 3));
                return(time.AddDays(-time.Day + 1));

            case ETimeType.Year:
                return(now.AddDays(-now.DayOfYear + 1));

            default:
                return(null);
            }
        }
예제 #7
0
        /// <summary>
        /// 获取结束时间
        /// </summary>
        /// <param name="TimeType">Week、Month、Season、Year</param>
        /// <param name="now"></param>
        /// <returns></returns>
        public static DateTime?GetTimeEndByType(ETimeType TimeType, DateTime now)
        {
            switch (TimeType)
            {
            case ETimeType.Week:
                return(now.AddDays(7 - (int)now.DayOfWeek));

            case ETimeType.Month:
                return(now.AddMonths(1).AddDays(-now.AddMonths(1).Day + 1).AddDays(-1));

            case ETimeType.Season:
                var time = now.AddMonths((3 - ((now.Month - 1) % 3) - 1));
                return(time.AddMonths(1).AddDays(-time.AddMonths(1).Day + 1).AddDays(-1));

            case ETimeType.Year:
                var time2 = now.AddYears(1);
                return(time2.AddDays(-time2.DayOfYear));

            default:
                return(null);
            }
        }