History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: TIMELINE-70
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: David F. Huynh
Reporter: Alex McCarrier
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Timeline

time zone in event popup bubble is incorrect

Created: 26/Mar/07 04:09 PM   Updated: 29/Oct/07 05:19 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Environment: firefox 2.0.0.3, mac osx


 Description  « Hide
I initialized my timeline bands to my local time zone, and the times in the event data use my local time zone, and the times shown in the event popup bubbles are correct but they always show GMT as the time zone. IE:

<event start="Mar 15 2007 15:02:00 CDT" end="Mar 15 2007 15:02:00 CDT" isDuration="false" title="Actual Start Time">ACTUAL_START</event>

In the popup bubble will show Mar 15 2007 15:02:00 GMT.

 All   Comments   Change History      Sort Order:
Ben Ostrowsky - 23/Apr/07 11:53 AM
We're having the same problem too. Our event source is JSON, and our time information looks like this:
      "start" : "2004-10-29T09:00:00-0400",
      "end" : "2004-10-29T16:00:00-0400"


Frank Spangenberg - 24/Sep/07 08:46 AM
Was someone able to fix this?

David F. Huynh - 24/Sep/07 01:46 PM
I will try to fix it in version 2.0. For the time being, please try to add this script after you include timeline-api.js:

<script>
Timeline.DefaultEventSource.Event.prototype.fillTime = function(elmt, labeller) {
        if (this._instant) {
            if (this.isImprecise()) {
                elmt.appendChild(elmt.ownerDocument.createTextNode(this.getProperty("start")));
                elmt.appendChild(elmt.ownerDocument.createElement("br"));
                elmt.appendChild(elmt.ownerDocument.createTextNode(this.getProperty("end")));
            } else {
                elmt.appendChild(elmt.ownerDocument.createTextNode(this.getProperty("start")));
            }
        } else {
            if (this.isImprecise()) {
                elmt.appendChild(elmt.ownerDocument.createTextNode(
                    this.getProperty("start") + " ~ " + this.getProperty("latestStart")));
                elmt.appendChild(elmt.ownerDocument.createElement("br"));
                elmt.appendChild(elmt.ownerDocument.createTextNode(
                    this.getProperty("earliestEnd") + " ~ " + this.getProperty("end")));
            } else {
                elmt.appendChild(elmt.ownerDocument.createTextNode(this.getProperty("start")));
                elmt.appendChild(elmt.ownerDocument.createElement("br"));
                elmt.appendChild(elmt.ownerDocument.createTextNode(this.getProperty("end")));
            }
        }
    };
</script>

Let me know if that helps.

Frank Spangenberg - 25/Sep/07 02:57 AM
Thank you for your fast response and the fix!
It helps very well!

Oleg Krapilsky - 29/Oct/07 05:19 PM
I made the following changes to date-time.js and labellers.js; now, setIso8601Time() makes use of time zone information present in ISO timestamps instead of discarding it, labelPrecise() displays GMT offset, and parseGregorianDateTime() no longer defaults to your local time zone when dealing with timestamps without any time zone info.

<pre>
&lt;script&gt;

Timeline.DateTime.setIso8601Time = function (dateObject, string) {
    var timezone = "Z|(([-+])([0-9]{2})(:?([0-9]{2}))?)$";
    var d = string.match(new RegExp(timezone));

    var offset = 0;
    if (d) {
        if (d[0] != 'Z') {
            offset = (Number(d[3]) * 60) + Number(d[5]);
            offset *= ((d[2] == '-') ? 1 : -1);
        }
        string = string.substr(0, string.length - d[0].length);
    }

    var regexp = "^([0-9]{2})(:?([0-9]{2})(:?([0-9]{2})(\.([0-9]+))?)?)?$";
    var d = string.match(new RegExp(regexp));
    if(!d) {
        dojo.debug("invalid time string: " + string);
        return false;
    }
    var hours = d[1];
    var mins = Number((d[3]) ? d[3] : 0);
    var secs = (d[5]) ? d[5] : 0;
    var ms = d[7] ? (Number("0." + d[7]) * 1000) : 0;

    dateObject.setUTCHours(hours);
    dateObject.setUTCMinutes(mins);
    dateObject.setUTCSeconds(secs);
    dateObject.setUTCMilliseconds(ms);

    // This part was missing from dojo prior to v0.4.3, causing all sorts of trouble.
    
    if (offset !== 0) {
        dateObject.setTime(dateObject.getTime() + offset * 60000);
    }

    return dateObject;
};

Timeline.GregorianDateLabeller.prototype.labelPrecise = function(date) {
    return ((Timeline.DateTime.removeTimeZoneOffset(
        date,
        this._timeZone
    ).toUTCString()) + (this._timeZone < 0 ? "" : "+" ) + this._timeZone);
};

Timeline.DateTime.parseGregorianDateTime = function(o) {
    if (o == null) {
        return null;
    } else if (o instanceof Date) {
        return o;
    }
    
    var s = o.toString();
    if (s.length > 0 && s.length < 8) {
        var space = s.indexOf(" ");
        if (space > 0) {
            var year = parseInt(s.substr(0, space));
            var suffix = s.substr(space + 1);
            if (suffix.toLowerCase() == "bc") {
                year = 1 - year;
            }
        } else {
            var year = parseInt(s);
        }
            
        var d = new Date(0);
        d.setUTCFullYear(year);
        
        return d;
    }

    // I miss in_array() so much.
    
    var appendGMT0 = true;
    var timeZoneCodes = ["GMT", "UTC", "PST", "MST", "CST", "EST"];
    for (var i = 0; i < timeZoneCodes.length; i++) {
     if((s.match(timeZoneCodes[i])) != null) {
     appendGMT0 = false;
     break;
     }
    }
    
    if (appendGMT0 == true)
     s = s + " GMT+0000";
    
    try {
        return new Date(Date.parse(s));
    } catch (e) {
        return null;
    }
};

&lt;/script&gt;
</pre>