Example #1
0
        public utc offset_hour(int h)
        {
            utc total = new utc(year, month, date, hour, minute, sec);

            if (h > 0)
            {
                if (hour + h < 24)
                {
                    total.hour += h;
                }
                else if (date < JTime.date_amount_of_month(total.year, total.month))
                {
                    total.date += 1;
                    total.hour  = total.hour - 24 + h;
                }
                else if (month <= 11)
                {
                    total.month += 1;
                    total.date   = 1;
                    total.hour   = total.hour - 24 + h;
                }
                else
                {
                    total.year += 1;
                    total.month = 1;
                    total.date  = 1;
                    total.hour  = total.hour - 24 + h;
                }
                return(total);
            }
            else if (h < 0)
            {
                h = -h;
                if (hour >= h)
                {
                    total.hour -= h;
                }
                else if (date > 1)
                {
                    total.date -= 1;
                    total.hour  = total.hour + 24 - h;
                }
                else if (month > 1)
                {
                    total.month -= 1;
                    total.date   = total.date - 1 + JTime.date_amount_of_month(total.year, total.month);
                    total.hour   = total.hour + 24 - h;
                }
                else
                {
                    total.year  -= 1;
                    total.month += 11;
                    total.date   = total.date - 1 + JTime.date_amount_of_month(total.year, total.month);
                    total.hour   = total.hour + 24 - h;
                }
                return(total);
            }
            return(total);
        }
Example #2
0
 private void get_doy()
 {
     doy = 0;
     for (int i = 1; i < cur.month; i++)
     {
         doy += JTime.date_amount_of_month(cur.year, i);
     }
     doy += cur.date;
 }
Example #3
0
        public void change_to_doy(int doy)
        {
            int temp = doy;

            for (int i = 1; i <= 12; i++)
            {
                temp = JTime.date_amount_of_month(year, i);
                if (doy <= temp)
                {
                    month = i;
                    date  = doy;
                    return;
                }
                else
                {
                    doy -= temp;
                }
            }
            throw new Exception();
        }