db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jack Klebanoff <klebanoff-de...@sbcglobal.net>
Subject [PATCH] Conversions to Date and Timestamp
Date Mon, 25 Apr 2005 17:34:05 GMT
The attached path contains some fixes to conversions to dates and 
timestamps.
1. According to the Derby documentation the DATE and TIMESTAMP functions 
provide some conversions beyond those handled by the normal casts. This 
patch implements them. The DATE function converts a numeric argument to 
a date by taking the integer portion of the number and considering it as 
the number of days since Jan. 1 1970. The DATE function also handles a 
string of length 7 in the format 'yyyyddd'. It is taken to indicate the 
ddd'th day of year yyyy. The TIMESTAMP function handles string arguments 
of length 14 in the format 'yyyyMMddhhmmss'. Any other arguments to the 
DATE and TIMESTAMP functions are handled as normal casts to date or 
timestamp.

(The TIME function does not do any special conversions. It is the same 
as the CAST function).

2. The string to time cast has been made more lenient by making the 
seconds field optional.

Previously the DATE and unary TIMESTAMP functions were implemented by 
converting them to calls to CAST. This was done in the parser. The patch 
changes this. The parser now generates a UnaryDateTimestampOperatorNode 
to represent these functions. The generated code calls new 
DataValueFactory methods. Most of the actual work is done in the SQLDate 
and SQLTimestamp classes.

The patch passed the derbyall suite.

Jack Klebanoff

Mime
View raw message