예제 #1
0
        public int GetArg_Date(string str, out GPGregorianTime vc)
        {
            vc = new GPGregorianTime(GPLocation.getEmptyLocation());
            string[] parts = str.Replace('/', '-').Split('-');
            if (parts.Length < 3)
            {
                return(1);
            }
            int day, month, year;

            int.TryParse(parts[0], out day);
            if (day == 0)
            {
                day = 1;
            }
            int.TryParse(parts[1], out month);
            if (month == 0)
            {
                month = 1;
            }
            int.TryParse(parts[2], out year);

            vc.setDate(year, month, day);
            return(0);
        }
예제 #2
0
        public int GetArg_Time(string str, out GPGregorianTime vc)
        {
            vc = new GPGregorianTime(GPLocation.getEmptyLocation());
            double l          = 0.0;
            double coma       = 10.0;
            bool   after_coma = false;
            bool   is_deg     = false;

            string s = str;

            foreach (char ch in str)
            {
                switch (ch)
                {
                case '0':
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                    if (after_coma)
                    {
                        if (is_deg)
                        {
                            l += (ch - '0') * 5.0 / (coma * 3.0);
                        }
                        else
                        {
                            l += (ch - '0') / coma;
                        }
                        coma *= 10.0;
                    }
                    else
                    {
                        l = l * 10.0 + (ch - '0');
                    }
                    break;

                case ':':
                    after_coma = true;
                    is_deg     = true;
                    break;

                default:
                    return(SetArgLastError(14));
                }
            }

            vc.setDayHours(l / 24.0);

            return(0);
        }