Open GoogleCodeExporter opened 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
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
[deleted comment]
<!-- 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
Original issue reported on code.google.com by
vaibhr...@gmail.com
on 3 Oct 2011 at 6:16