mayyangtaiwan / simile-widgets

Automatically exported from code.google.com/p/simile-widgets
0 stars 0 forks source link

I dont want time in Bubble popups date #452

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.click on any event, bubble popup will open
2.see date format
3.

What is the expected output? What do you see instead?
I just want "Sat Jan 4 2011" instead of "Sat Jan 4 18:30:00 UTC+0530 2011"

What version of the product are you using? On what browser and what
operating system?
I am using IE8 with Windows OS

Please provide any additional information below.
I need to change date time format on bubble popup

Original issue reported on code.google.com by vaibhr...@gmail.com on 3 Oct 2011 at 6:16

GoogleCodeExporter commented 8 years ago
Same applies to me. I'd like to produce German sort of date, like "So, 1.1.2012 
15:00 Uhr" instead of "Sun Jan 1 2012...". Any idea? Thanks a lot.

Original comment by harald.r...@gmail.com on 7 Dec 2011 at 7:05

GoogleCodeExporter commented 8 years ago
I poked around in the source code and found the function that is responsible 
for outputting the date.
Timeline.GregorianDateLabeller.prototype.labelPrecise = function(date) {
    return SimileAjax.DateTime.removeTimeZoneOffset(
        date, 
        this._timeZone //+ (new Date().getTimezoneOffset() / 60)
    ).toUTCString();
};
Notice the .toUTCString()

To change the date format you'll have to override this function in your code 
after you have loaded timeline-api.js and before initialising your timeline.
for example to display only the date (in long format):

    Timeline.GregorianDateLabeller.prototype.labelPrecise = function (date) {
    return SimileAjax.DateTime.removeTimeZoneOffset(
            date,
            this._timeZone //+ (new Date().getTimezoneOffset() / 60)
        ).toLocaleDateString();
    };

I don't know the importance of the removeTimeZoneOffset-function, so I just 
left it alone. Have a look at 
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date for 
all functions regarding to the Date-object.

Original comment by flot...@gmail.com on 12 Dec 2011 at 7:46

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
<!-- monkey patch timeline use of toUTCScring  -->
    <script>
    Timeline.GregorianDateLabeller.prototype.labelPrecise = function(tdate) {
        //var tdate = SimileAjax.DateTime.removeTimeZoneOffset(
        //        date,
        //        this._timeZone
        //    )  //.toUTCString().replace(/GMT/, '');

        var x = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
        var day  = x[tdate.getDay()];
        var date = tdate.getDate();         
        var y = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
        var month = y[tdate.getMonth()];        
        var year = tdate.getFullYear();
        var hours = tdate.getHours();
        var minutes = tdate.getMinutes();
        minutes = ( minutes < 10 ? "0" : "" ) + minutes;
        var seconds = tdate.getSeconds();
        seconds = ( seconds < 10 ? "0" : "" ) + seconds;
        var millisecs = tdate.getMilliseconds();
        millisecs = ( millisecs < 100 ? "0" : "" ) + millisecs;
        millisecs = ( millisecs < 10 ? "0" : "" ) + millisecs;

        dateStr = day + ", " + date + " " + month + " " + year + " " + hours + ":" + minutes + ":" + seconds + "." + millisecs;
        return dateStr;
    }
    </script>

Original comment by David.C....@gmail.com on 8 Aug 2014 at 9:55