// Copyright 2007, Sally Balick. All Rights Reserved.

// converts a timestamp to iso date and/or time (yyyy-mm-dd hh:mm)
function tsToIsoDateTime(ts, showDate, showTime) {
    var date = new Date();
    date.setTime(ts);
    var res = '';
    var x;
    
    if(showDate) {
    	res += date.getFullYear() + '-';
	x = date.getMonth() + 1;
	res += ((x < 10) ? ('0' + x) : x) + '-';
	x = date.getDate();
	res += ((x < 10) ? ('0' + x) : x);
	if(showTime)
	    res += ' ';
    }
    if(showTime) {
	x = date.getHours();
	res += ((x < 10) ? ('0' + x) : x) + ':';
	x = date.getMinutes();
	res += ((x < 10) ? ('0' + x) : x);
    }
    return res;
}

// simple stringbuffer functionality
function StringBuffer() {
    this.buffer = [];
}
StringBuffer.prototype.append = function(string) {
    this.buffer.push(string); return this;
}
StringBuffer.prototype.toString = function() {
    return this.buffer.join("");
}

