Optimization of code based on dates
#6

Well yes, you're being extremely accurate, thus your code is perfectly correct and clean.
An idea like:
pawn Код:
if(!strcmp(period, "second",true))
        {
            second = time;
        }
        if(!strcmp(period, "minute", true))
        {
            second = time/60;
        }
        if(!strcmp(period, "hour", true))
        {
            second = time/60;
            second = second/60;
        }
        if(!strcmp(period, "day", true))
        {
            second = time/60;
            second = second/60;
            second = second/24;
        }
        if(!strcmp(period, "week", true))
        {
            second = time/60;
            second = second/60;
            second = second/24;
            second = second/7;
        }
        if(!strcmp(period, "month", true))
        {
            second = time/60;
            second = second/60;
            second = second/24;
            second = second/7;
            second = second/30; //Here is the inaccuracy that you lose, the few days difference in the 30 to 31 month range.
        }
        if(!strcmp(period, "year", true))
        {
            second = time/60;
            second = second/60;
            second = second/24;
            second = second/30;
            second = second/12;
        }
Is inaccurate, but I'm sure you've already thought of that.
Reply


Messages In This Thread
Optimization of code based on dates - by LarzI - 13.12.2012, 23:30
Re: Optimization of code based on dates - by Jefff - 13.12.2012, 23:56
Re: Optimization of code based on dates - by LarzI - 13.12.2012, 23:58
Re: Optimization of code based on dates - by maramizo - 13.12.2012, 23:58
Re: Optimization of code based on dates - by LarzI - 14.12.2012, 00:05
Re: Optimization of code based on dates - by maramizo - 14.12.2012, 00:18
Re: Optimization of code based on dates - by LarzI - 14.12.2012, 00:24
Re: Optimization of code based on dates - by maramizo - 14.12.2012, 00:35
Re: Optimization of code based on dates - by LarzI - 14.12.2012, 01:31
Re: Optimization of code based on dates - by maramizo - 14.12.2012, 02:07

Forum Jump:


Users browsing this thread: 1 Guest(s)