示例#1
0
 getTime(TimeZone tz)
 {
     /*
     ** Ingres dates are overloaded with 'empty' date,
     ** date only, timestamp and interval values.  The
     ** first three types are handled explicitly below.
     ** Intervals will either cause an exception while
     ** attempting to parse the value or as the default
     ** action for an unrecognized format.
     */
     try
     {
         if (value.Length == 0 ||                                        // Empty date
             value.Length == SqlDates.D_FMT.Length)                      // Date only
         {
             /*
             ** There is no time component, so create a time EPOCH value.
             ** If no timezone is provided, we can return the local epoch
             ** constant.  Otherwise, the epoch value for the requested
             ** timezone must be generated.
             */
             return((tz == null) ? SqlDates.getEpochTime()
                                         : SqlDates.parseTime(SqlDates.T_EPOCH, tz));
         }
         else if (value.Length == SqlDates.TS_FMT.Length)                        // Timestamp
         {
             /*
             ** Remove the date component but retain correct time:
             **
             ** 1.  Convert to GMT timestamp using TZ for current connection.
             ** 2.  Re-format as time only using local TZ to get local time.
             ** 3.  Generate Time value using requested/local TZ.
             */
             DateTime ts  = SqlDates.parseTimestamp(value, use_gmt);
             String   str = SqlDates.formatTime(ts, false);
             return((osql_dates && tz != null)
                                         ? SqlDates.parseTime(str, tz)
                                         : SqlDates.parseTime(str, false));
         }
         else                                                                    // Interval
         {
             /*
             ** Can't support intervals with Time objects.
             */
             throw SqlEx.get(ERR_GC401B_INVALID_DATE);
         }
     }
     catch (SqlEx ex)
     {
         /*
         ** Any parsing error is assumed to be caused by an interval.
         */
         interval = true;
         throw ex;
     }
 }         // getTime