Esempio n. 1
0
        formatOffset(int offset)
        {
            String tzOffset = null;

            /*
            ** Since only a small number of timezones are expected
            ** to be active, a simple vector is used to map offsets.
            ** Enumerating through the ArrayList is not thread-safe.
            ** We lock the collection to avoid an enumerator throwing
            ** NullReferenceException should another thread modify
            ** the collection.
            */
            lock (tzoCache.SyncRoot)
            {
                for (int i = 0; i < tzoCache.Count; i++)
                {
                    IdMap tzo = (IdMap)tzoCache[i];

                    if (tzo.equals(offset))
                    {
                        tzOffset = tzo.ToString();
                        break;
                    }
                }

                if (tzOffset == null)
                {
                    bool neg = (offset < 0);
                    if (neg)
                    {
                        offset = -offset;
                    }
                    int hour   = offset / 60;
                    int minute = offset % 60;

                    char[] format = new char[6];
                    format[0] = neg ? '-' : '+';
                    format[1] = digits[(hour / 10) % 10];
                    format[2] = digits[hour % 10];
                    format[3] = ':';
                    format[4] = digits[(minute / 10) % 10];
                    format[5] = digits[minute % 10];

                    if (neg)
                    {
                        offset = -offset;                               // Restore original offset
                    }
                    tzOffset = new String(format);
                    tzoCache.Add(new IdMap(offset, tzOffset));
                }
            }              // end lock (tzoCache.SyncRoot)

            return(tzOffset);
        }         // formatOffset
Esempio n. 2
0
        internal static string GetDataTypeName(
            ProviderType i, bool isANSIDateTimeSupported)
        {
            switch (i)
            {
            case ProviderType.BigInt:
                return(IdMap.get(8, DbmsConst.intMap));                          // integer8

            case ProviderType.Integer:
                return(IdMap.get(4, DbmsConst.intMap));                          // integer

            case ProviderType.SmallInt:
                return(IdMap.get(2, DbmsConst.intMap));                          // smallint

            case ProviderType.TinyInt:
                return(IdMap.get(1, DbmsConst.intMap));                          // tinyint

            case ProviderType.Double:
                return(IdMap.get(8, DbmsConst.floatMap));                        // float8

            case ProviderType.Real:
                return(IdMap.get(4, DbmsConst.floatMap));                        // real

            case ProviderType.Binary:
                return(IdMap.get(DbmsConst.DBMS_TYPE_BYTE,
                                 DbmsConst.typeMap));                                // byte

            case ProviderType.Char:
                return(IdMap.get(DbmsConst.DBMS_TYPE_CHAR,
                                 DbmsConst.typeMap));                                // char

            case ProviderType.DateTime:
                if (isANSIDateTimeSupported)
                {
                    return(IdMap.get(DbmsConst.DBMS_TYPE_TSWO,
                                     DbmsConst.typeMap));                                // date (TS w/o TZ)
                }
                else
                {
                    return(IdMap.get(DbmsConst.DBMS_TYPE_IDATE,
                                     DbmsConst.typeMap));                                // date
                }

            case ProviderType.IngresDate:
                if (isANSIDateTimeSupported)
                {
                    return(IdMap.get(DbmsConst.DBMS_TYPE_INGRESDATE,
                                     DbmsConst.typeMap));                                // ingresdate
                }
                else
                {
                    return(IdMap.get(DbmsConst.DBMS_TYPE_IDATE,
                                     DbmsConst.typeMap));                                // date
                }

            case ProviderType.Decimal:
                return(IdMap.get(DbmsConst.DBMS_TYPE_DECIMAL,
                                 DbmsConst.typeMap));                                // decimal

            case ProviderType.LongNVarChar:
                return(IdMap.get(DbmsConst.DBMS_TYPE_LONG_NCHAR,
                                 DbmsConst.typeMap));                                // long nvarchar

            case ProviderType.LongVarBinary:
                return(IdMap.get(DbmsConst.DBMS_TYPE_LONG_BYTE,
                                 DbmsConst.typeMap));                                // long byte

            case ProviderType.LongVarChar:
                return(IdMap.get(DbmsConst.DBMS_TYPE_LONG_CHAR,
                                 DbmsConst.typeMap));                                // long varchar

            case ProviderType.NChar:
                return(IdMap.get(DbmsConst.DBMS_TYPE_NCHAR,
                                 DbmsConst.typeMap));                                // nchar

            case ProviderType.NVarChar:
                return(IdMap.get(DbmsConst.DBMS_TYPE_NVARCHAR,
                                 DbmsConst.typeMap));                                // nvarchar

            case ProviderType.VarBinary:
                return(IdMap.get(DbmsConst.DBMS_TYPE_VARBYTE,
                                 DbmsConst.typeMap));                                // byte varying

            case ProviderType.VarChar:
                return(IdMap.get(DbmsConst.DBMS_TYPE_VARCHAR,
                                 DbmsConst.typeMap));                                // varchar

            case ProviderType.Date:
                return(IdMap.get(DbmsConst.DBMS_TYPE_ADATE,
                                 DbmsConst.typeMap));                                // ansi date

            case ProviderType.Time:
                return(IdMap.get(DbmsConst.DBMS_TYPE_TMWO,
                                 DbmsConst.typeMap));                                // ansi time w/o TZ

            case ProviderType.Interval:
                return(IdMap.get(DbmsConst.DBMS_TYPE_INTDS,
                                 DbmsConst.typeMap));                                // generic interval

            case ProviderType.IntervalDayToSecond:
                return(IdMap.get(DbmsConst.DBMS_TYPE_INTDS,
                                 DbmsConst.typeMap));                                // interval d_s

            case ProviderType.IntervalYearToMonth:
                return(IdMap.get(DbmsConst.DBMS_TYPE_INTYM,
                                 DbmsConst.typeMap));                                // interval y_m

            case ProviderType.Boolean:
                return(IdMap.get(DbmsConst.DBMS_TYPE_BOOL,
                                 DbmsConst.typeMap));                                // boolean

            default:
                return("unknownDbType" + i.ToString());
            }
        }          // GetDataTypeName