Ejemplo n.º 1
0
        public static int GetDateCount(DateUtil.TimeUnit tu, int value)
        {
            switch (tu)
            {
            case DateUtil.TimeUnit.day:
            {
                return(value * 1);
            }

            case DateUtil.TimeUnit.month:
            {
                return(value * 30);
            }

            case DateUtil.TimeUnit.week:
            {
                return(value * 7);
            }

            default:
            {
                break;
            }
            }
            return(1);
        }
Ejemplo n.º 2
0
        public static long GetMiniseconds(DateUtil.TimeUnit tu, double value)
        {
            double d;

            switch (tu)
            {
            case DateUtil.TimeUnit.day:
            {
                d = 86400000 * value;
                break;
            }

            case DateUtil.TimeUnit.month:
            {
                d = 2592000000 * value;
                break;
            }

            case DateUtil.TimeUnit.week:
            {
                d = 604800000 * value;
                break;
            }

            case DateUtil.TimeUnit.hour:
            {
                d = 3600000 * value;
                break;
            }

            case DateUtil.TimeUnit.minute:
            {
                d = 60000 * value;
                break;
            }

            case DateUtil.TimeUnit.second:
            {
                d = 1000 * value;
                break;
            }

            default:
            {
                d = 0;
                break;
            }
            }
            return((long)d);
        }
Ejemplo n.º 3
0
        public static IList <DateTime> GetDateList(DateUtil.TimeUnit tu, int value, int displayCount, DateTime earliestDay)
        {
            double count = MyMath.Min(GetDateCount(tu, value), GetTimeValue(DateUtil.TimeUnit.day, new DateTime(), earliestDay));
            double fre   = count / displayCount;

            if (fre < 1)
            {
                displayCount = (int)count;
                fre          = 1;
            }
            IList <DateTime> list = new List <DateTime>();

            for (int i = 1; i < displayCount + 1; i++)
            {
                list.Add(GetBeforeDay(DateUtil.TimeUnit.day, (displayCount - i) * fre));
            }
            return(list);
        }
Ejemplo n.º 4
0
        public static DateTime GetBeforeDay(DateUtil.TimeUnit tu, double value)
        {
            double time = 1;

            switch (tu)
            {
            case DateUtil.TimeUnit.day:
            {
                time = 86400000;
                break;
            }

            case DateUtil.TimeUnit.month:
            {
                time = value * 2592000000;
                break;
            }

            case DateUtil.TimeUnit.week:
            {
                time = value * 604800000;
                break;
            }

            case DateUtil.TimeUnit.hour:
            {
                time = value * 3600000;
                break;
            }

            case DateUtil.TimeUnit.minute:
            {
                time = value * 60000;
                break;
            }

            case DateUtil.TimeUnit.second:
            {
                time = value * 1000;
                break;
            }
            }
            return(new DateTime(Runtime.CurrentTimeMillis(false) - (long)time));
        }
Ejemplo n.º 5
0
        public static double GetTimeValue(DateUtil.TimeUnit tu, DateTime date1, DateTime date2)
        {
            switch (tu)
            {
            case DateUtil.TimeUnit.day:
            {
                return(GetTimeByDay(date1, date2));
            }

            case DateUtil.TimeUnit.month:
            {
                return(GetTimeByMonth(date1, date2));
            }

            case DateUtil.TimeUnit.week:
            {
                return(GetTimeByWeek(date1, date2));
            }

            case DateUtil.TimeUnit.hour:
            {
                return(GetTimeByHour(date1, date2));
            }

            case DateUtil.TimeUnit.minute:
            {
                return(GetTimeByMinute(date1, date2));
            }

            case DateUtil.TimeUnit.second:
            {
                return(GetTimeBySecond(date1, date2));
            }

            default:
            {
                return(0);
            }
            }
        }