예제 #1
0
파일: Month.cs 프로젝트: nesrinesghaier/upa
        public override string ToString()
        {
            Net.Vpc.Upa.Types.Calendar calendar = Net.Vpc.Upa.Types.Calendar.GetInstance();
            calendar.SetTimeInMillis(GetTime());
            int year  = calendar.Get(Net.Vpc.Upa.Types.Calendar.YEAR) + 1900;
            int month = calendar.Get(Net.Vpc.Upa.Types.Calendar.MONTH) + 1;

            char[] buf = "2000-00".ToCharArray();
            buf[0] = (char)('0' + (year / 1000));
            buf[1] = (char)('0' + ((year / 100) % 10));
            buf[2] = (char)('0' + ((year / 10) % 10));
            buf[3] = (char)('0' + (year % 10));
            buf[5] = (char)('0' + (month / 10));
            buf[6] = (char)('0' + (month % 10));
            return(new string(buf));
        }
예제 #2
0
파일: Date.cs 프로젝트: nesrinesghaier/upa
        public override string ToString()
        {
            Net.Vpc.Upa.Types.Calendar c = Net.Vpc.Upa.Types.Calendar.GetInstance();
            c.SetTime(this);
            int year  = c.Get(Net.Vpc.Upa.Types.Calendar.YEAR);
            int month = c.Get(Net.Vpc.Upa.Types.Calendar.MONTH) + 1;
            int day   = c.Get(Net.Vpc.Upa.Types.Calendar.DAY_OF_MONTH);

            char[] buf = "2000-00-00".ToCharArray();
            buf[0] = (char)('0' + (year / 1000));
            buf[1] = (char)('0' + ((year / 100) % 10));
            buf[2] = (char)('0' + ((year / 10) % 10));
            buf[3] = (char)('0' + (year % 10));
            buf[5] = (char)('0' + (month / 10));
            buf[6] = (char)('0' + (month % 10));
            buf[8] = (char)('0' + (day / 10));
            buf[9] = (char)('0' + (day % 10));
            return(new string(buf));
        }
예제 #3
0
파일: Year.cs 프로젝트: nesrinesghaier/upa
 public override string ToString() {
     Net.Vpc.Upa.Types.Calendar c = Net.Vpc.Upa.Types.Calendar.GetInstance();
     c.SetTime(this);
     int year = c.Get(Net.Vpc.Upa.Types.Calendar.YEAR) + 1900;
     char[] buf = "2000".ToCharArray();
     buf[0] = (char) ('0' + (year / 1000));
     buf[1] = (char) (((year / 100) % 10));
     buf[2] = (char) (((year / 10) % 10));
     buf[3] = (char) ((year % 10));
     return new string(buf);
 }
예제 #4
0
파일: Time.cs 프로젝트: nesrinesghaier/upa
        public override string ToString()
        {
            Net.Vpc.Upa.Types.Calendar c = Net.Vpc.Upa.Types.Calendar.GetInstance();
            c.SetTimeInMillis(GetTime());
            int    hour   = c.Get(Net.Vpc.Upa.Types.Calendar.HOUR_OF_DAY);
            int    minute = c.Get(Net.Vpc.Upa.Types.Calendar.MINUTE);
            int    second = c.Get(Net.Vpc.Upa.Types.Calendar.SECOND);
            string hourString;
            string minuteString;
            string secondString;

            if (hour < 10)
            {
                hourString = "0" + hour;
            }
            else
            {
                hourString = System.Convert.ToString(hour);
            }
            if (minute < 10)
            {
                minuteString = "0" + minute;
            }
            else
            {
                minuteString = System.Convert.ToString(minute);
            }
            if (second < 10)
            {
                secondString = "0" + second;
            }
            else
            {
                secondString = System.Convert.ToString(second);
            }
            return(hourString + ":" + minuteString + ":" + secondString);
        }
예제 #5
0
        public override string ToString()
        {
            Net.Vpc.Upa.Types.Calendar c = Net.Vpc.Upa.Types.Calendar.GetInstance();
            c.SetTimeInMillis(GetTime());
            int year   = c.Get(Net.Vpc.Upa.Types.Calendar.YEAR);
            int month  = c.Get(Net.Vpc.Upa.Types.Calendar.MONTH) + 1;
            int day    = c.Get(Net.Vpc.Upa.Types.Calendar.DAY_OF_MONTH);
            int hour   = c.Get(Net.Vpc.Upa.Types.Calendar.HOUR_OF_DAY);
            int minute = c.Get(Net.Vpc.Upa.Types.Calendar.MINUTE);
            int second = c.Get(Net.Vpc.Upa.Types.Calendar.SECOND);
            //        int year = super.getYear() + 1900;
            //        int month = super.getMonth() + 1;
            //        int day = super.getDate();
            //        int hour = super.getHours();
            //        int minute = super.getMinutes();
            //        int second = super.getSeconds();
            string yearString;
            string monthString;
            string dayString;
            string hourString;
            string minuteString;
            string secondString;
            string nanosString;
            string zeros     = "000000000";
            string yearZeros = "0000";

            System.Text.StringBuilder timestampBuf;
            if (year < 1000)
            {
                // Add leading zeros
                yearString = "" + year;
                yearString = yearZeros.Substring(0, (4 - (yearString).Length)) + yearString;
            }
            else
            {
                yearString = "" + year;
            }
            if (month < 10)
            {
                monthString = "0" + month;
            }
            else
            {
                monthString = System.Convert.ToString(month);
            }
            if (day < 10)
            {
                dayString = "0" + day;
            }
            else
            {
                dayString = System.Convert.ToString(day);
            }
            if (hour < 10)
            {
                hourString = "0" + hour;
            }
            else
            {
                hourString = System.Convert.ToString(hour);
            }
            if (minute < 10)
            {
                minuteString = "0" + minute;
            }
            else
            {
                minuteString = System.Convert.ToString(minute);
            }
            if (second < 10)
            {
                secondString = "0" + second;
            }
            else
            {
                secondString = System.Convert.ToString(second);
            }
            if (nanos == 0)
            {
                nanosString = "0";
            }
            else
            {
                nanosString = System.Convert.ToString(nanos);
                // Add leading zeros
                nanosString = zeros.Substring(0, (9 - (nanosString).Length)) + nanosString;
                // Truncate trailing zeros
                char[] nanosChar = new char[(nanosString).Length];
                nanosString.CopyTo(0, nanosChar, 0, ((nanosString).Length) - (0));
                int truncIndex = 8;
                while (nanosChar[truncIndex] == '0')
                {
                    truncIndex--;
                }
                nanosString = new string(nanosChar, 0, truncIndex + 1);
            }
            // do a string buffer here instead.
            timestampBuf = new System.Text.StringBuilder(20 + (nanosString).Length);
            timestampBuf.Append(yearString);
            timestampBuf.Append("-");
            timestampBuf.Append(monthString);
            timestampBuf.Append("-");
            timestampBuf.Append(dayString);
            timestampBuf.Append(" ");
            timestampBuf.Append(hourString);
            timestampBuf.Append(":");
            timestampBuf.Append(minuteString);
            timestampBuf.Append(":");
            timestampBuf.Append(secondString);
            timestampBuf.Append(".");
            timestampBuf.Append(nanosString);
            return(timestampBuf.ToString());
        }
예제 #6
0
        public virtual object Eval(Net.Vpc.Upa.EvalContext evalContext)
        {
            object[] arg = evalContext.GetArguments();
            Net.Vpc.Upa.Expressions.DatePartType type = (Net.Vpc.Upa.Expressions.DatePartType)arg[0];
            object count = (object)arg[1];

            Net.Vpc.Upa.Types.Date     date     = (Net.Vpc.Upa.Types.Date)arg[2];
            Net.Vpc.Upa.Types.Calendar instance = Net.Vpc.Upa.Types.Calendar.GetInstance();
            instance.SetTime(date);
            int f = -1;

            switch (type)
            {
            case Net.Vpc.Upa.Expressions.DatePartType.DATE:
            {
                f = Net.Vpc.Upa.Types.Calendar.DATE;
                break;
            }

            case Net.Vpc.Upa.Expressions.DatePartType.DAY:
            {
                f = Net.Vpc.Upa.Types.Calendar.DATE;
                break;
            }

            case Net.Vpc.Upa.Expressions.DatePartType.DAYOFMONTH:
            {
                f = Net.Vpc.Upa.Types.Calendar.DAY_OF_MONTH;
                break;
            }

            case Net.Vpc.Upa.Expressions.DatePartType.DAYOFWEEK:
            {
                f = Net.Vpc.Upa.Types.Calendar.DAY_OF_WEEK;
                break;
            }

            case Net.Vpc.Upa.Expressions.DatePartType.DAYOFYEAR:
            {
                f = Net.Vpc.Upa.Types.Calendar.DAY_OF_YEAR;
                break;
            }

            case Net.Vpc.Upa.Expressions.DatePartType.HOUR:
            {
                f = Net.Vpc.Upa.Types.Calendar.HOUR;
                break;
            }

            case Net.Vpc.Upa.Expressions.DatePartType.MILLISECOND:
            {
                f = Net.Vpc.Upa.Types.Calendar.MILLISECOND;
                break;
            }

            case Net.Vpc.Upa.Expressions.DatePartType.MINUTE:
            {
                f = Net.Vpc.Upa.Types.Calendar.MINUTE;
                break;
            }

            case Net.Vpc.Upa.Expressions.DatePartType.SECOND:
            {
                f = Net.Vpc.Upa.Types.Calendar.SECOND;
                break;
            }

            case Net.Vpc.Upa.Expressions.DatePartType.MONTH:
            {
                f = Net.Vpc.Upa.Types.Calendar.MONTH;
                break;
            }

            case Net.Vpc.Upa.Expressions.DatePartType.WEEK:
            {
                f = Net.Vpc.Upa.Types.Calendar.WEEK_OF_MONTH;
                break;
            }

            case Net.Vpc.Upa.Expressions.DatePartType.YEAR:
            {
                f = Net.Vpc.Upa.Types.Calendar.YEAR;
                break;
            }

            case Net.Vpc.Upa.Expressions.DatePartType.DAYOFWEEKNAME:
            {
                switch (instance.Get(Net.Vpc.Upa.Types.Calendar.DAY_OF_WEEK))
                {
                case 1:
                {
                    return("Sunday");
                }

                case 2:
                {
                    return("Monday");
                }

                case 3:
                {
                    return("Tuesday");
                }

                case 4:
                {
                    return("Wednesday");
                }

                case 5:
                {
                    return("Thursday");
                }

                case 6:
                {
                    return("Friday");
                }

                case 7:
                {
                    return("Saturday");
                }

                default:
                {
                    return("");
                }
                }
            }
            break;

            case Net.Vpc.Upa.Expressions.DatePartType.MONTHNAME:
            {
                switch (instance.Get(Net.Vpc.Upa.Types.Calendar.MONTH))
                {
                case 1:
                {
                    return("January");
                }

                case 2:
                {
                    return("February");
                }

                case 3:
                {
                    return("March");
                }

                case 4:
                {
                    return("April");
                }

                case 5:
                {
                    return("May");
                }

                case 6:
                {
                    return("June");
                }

                case 7:
                {
                    return("July");
                }

                case 8:
                {
                    return("August");
                }

                case 9:
                {
                    return("September");
                }

                case 10:
                {
                    return("October");
                }

                case 11:
                {
                    return("November");
                }

                case 12:
                {
                    return("December");
                }

                default:
                {
                    return("");
                }
                }
            }
            break;

            default:
            {
                throw new System.Exception("Unsupported");
            }
            }
            return(instance.Get(f));
        }
예제 #7
0
파일: Year.cs 프로젝트: nesrinesghaier/upa
 public virtual int GetGregorianYear() {
     Net.Vpc.Upa.Types.Calendar calendar = Net.Vpc.Upa.Types.Calendar.GetInstance();
     calendar.SetTimeInMillis(GetTime());
     return calendar.Get(Net.Vpc.Upa.Types.Calendar.YEAR);
 }