Issue Details (XML | Word | Printable)

Key: MPXDOC-35
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Charlie Dobbie
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Maven 1.x XDoc Plugin

xdoc-generated team list assumes an offset of -20 from GMT

Created: 22/Oct/03 07:57 PM   Updated: 01/Dec/03 09:31 AM   Resolved: 09/Nov/03 09:20 AM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Environment: maven-xdoc-plugin-1.4-SNAPSHOT, also exists in current HEAD as of reporting date


 Description  « Hide

The xdoc plugin uses velocity:merge to generate a team list from the pom data, using the plugin-resources\templates\team-list.xml template. This template contains the following JavaScript:

function offsetDate(id, offset) {
var date = new Date();
var dateOffset = new Date(
Date.UTC(
date.getFullYear(),
date.getMonth(),
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds()
) + (offset - 20) *60*60*1000);

document.getElementById(id).innerHTML = dateOffset;
}

JavaScript isn't my forte, but I believe this code assumes that the time zone offset given in the pom is going to be -20 offset from the browser's computer's time zone?

After a crash course in JavaScript this evening I think the following may work better:

function offsetDate(id, offset)
{
var now = new Date() ;
var nowTime = now.getTime() ;
var localOffset = now.getTimezoneOffset() ;
var developerTime = nowTime + (offset * 60 * 60 * 1000) + (localOffset * 60 * 1000) ;
var developerDate = new Date(developerTime) ;

document.getElementById(id).innerHTML = developerDate;
}

I strongly suggest people give it a go in a few different timezones before applying it! As I say I'm not a JavaScript guy, and may have totally the wrong end of the stick.



Charlie Dobbie added a comment - 22/Oct/03 08:20 PM

I should add that it works for me: WinME, GMT+1, IE5.5 and Mozilla 1.4.

To anyone who wants to try it: generate your site ("maven site"), edit target/docs/team-list.html and replace the current function with the new one. Then open the page and check the entries in the "Time" column are correct given the offset from GMT in "TZ Offset".


dion gillard added a comment - 09/Nov/03 09:15 AM

This looks cleaner. I'm testing it now.


dion gillard added a comment - 09/Nov/03 09:20 AM

Fix applied