xml-xalan-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 27365] New: - exslt extension function date-time() reports wrong GMT offsets.
Date Tue, 02 Mar 2004 13:30:34 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27365>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27365

exslt extension function date-time() reports wrong GMT offsets.

           Summary: exslt extension function date-time() reports wrong GMT
                    offsets.
           Product: XalanC
           Version: 1.7
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: XalanC
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: martin.benirschka@morganstanley.com
                CC: martin.benirschka@morganstanley.com


The XalanEXSLTFunctionDateTime calculates the GMT offset as the difference between the local
time hour and the gmt time hour. This calculation is 
valid only if the local date equals the gmt date. For instance, in New York (gmt offset =
-5:00) at 16 o'clock local time, the offset is correctly 
calculate as 16 - 21 = -5. However, at 20 o'clock, the offset is incorrectly calculated as
20 - 1 = 19.

The root cause is that the calculation does not take into account that the local time and
the gmt time may be associated with different dates. Here is 
the pseudo code for fixing this problem (just a suggestion, there may be a better way of getting
the correct gmt offset):

According to the exslt web site (http://www.exslt.org/date/functions/date-time/index.html),
the letter 'z' indicates a location in the gmt time zone, 
i.e., the offset equals zero.

If (date_local == date_gmt) {
	if (time_local == time_gmt) {
		offset = 'z'
	} else {
		offset = time_local - time_gmt
	}
	
} else if (date_local < date_gmt) {
	offset = time_local - time_gmt - 24
} else if (date_local > date_gmt) {
	offset = time_local - time_gmt + 24
}


To easily compare the date, on could create date integers for date_local and date_gmt:

date = (year * 10000) + (month * 100) + day

Mime
View raw message