function strftime(format,stamp) { var $t; if (typeof(format) == "undefined") $t = _strftime("TZ"); else if (typeof(stamp) == "undefined") $t = _strftime("TZ",format); else $t = _strftime("TZ",format,stamp); return $t; } function gmstrftime(format,stamp) { var $t; if (typeof(format) == "undefined") $t = _strftime("UTC"); else if (typeof(stamp) == "undefined") $t = _strftime("UTC",format); else $t = _strftime("UTC",format,stamp); return $t; } function _strftime(tz,format,stamp) { var my_format, my_time; if (typeof(format) == "undefined") { my_format = "%Y-%m-%d %H:%M:%S"; my_time = Number(new Date()) / 1000; } else if (typeof(stamp) == "undefined") { my_format = format; my_time = Number(new Date()) / 1000; } else { my_format = format; my_time = stamp; } if (my_time === false) { return "  "; } my_time = new Date(my_time*1000); my_format = my_format.replace("%D", "%m/%d/%y"); my_format = my_format.replace("%r", "%I:%M:%S %p"); if (tz == "TZ") { my_format = my_format.replace("%Y", "" + my_time.getFullYear()); my_format = my_format.replace("%y", "" + my_time.getFullYear()); my_format = my_format.replace("%m", pre0(my_time.getMonth()+1, 2)); my_format = my_format.replace("%d", pre0(my_time.getDate(), 2)); my_format = my_format.replace("%H", "" + pre0(my_time.getHours(), 2)); my_format = my_format.replace("%M", "" + pre0(my_time.getMinutes(), 2)); my_format = my_format.replace("%S", "" + pre0(my_time.getSeconds(), 2)); my_format = my_format.replace("%I", "" + ((my_time.getHours() + 11) % 12 + 1)); my_format = my_format.replace("%p", "" + (my_time.getHours() < 12 ? "AM" : "PM")); my_format = my_format.replace("%B", "" + getLang("months_long").split(",")[my_time.getMonth()]); my_format = my_format.replace("%b", "" + getLang("months_short").split(",")[my_time.getMonth()]); my_format = my_format.replace("%A", "" + getLang("day_long").split(",")[my_time.getDay()]); my_format = my_format.replace("%a", "" + getLang("day_short").split(",")[my_time.getDay()]); my_format = my_format.replace("%%", "%"); } if (tz == "UTC") { my_format = my_format.replace("%Y", "" + my_time.getUTCFullYear()); my_format = my_format.replace("%y", "" + my_time.getUTCFullYear()); my_format = my_format.replace("%m", pre0(my_time.getUTCMonth()+1, 2)); my_format = my_format.replace("%d", pre0(my_time.getUTCDate(), 2)); my_format = my_format.replace("%H", "" + pre0(my_time.getUTCHours(), 2)); my_format = my_format.replace("%M", "" + pre0(my_time.getUTCMinutes(), 2)); my_format = my_format.replace("%S", "" + pre0(my_time.getUTCSeconds(), 2)); my_format = my_format.replace("%I", "" + ((my_time.getUTCHours() + 11) % 12 + 1)); my_format = my_format.replace("%p", "" + (my_time.getUTCHours() < 12 ? "AM" : "PM")); my_format = my_format.replace("%B", "" + getLang("months_long").split(",")[my_time.getUTCMonth()]); my_format = my_format.replace("%b", "" + getLang("months_short").split(",")[my_time.getUTCMonth()]); my_format = my_format.replace("%A", "" + getLang("day_long").split(",")[my_time.getUTCDay()]); my_format = my_format.replace("%a", "" + getLang("day_short").split(",")[my_time.getUTCDay()]); my_format = my_format.replace("%%", "%"); } return my_format; } function pre0($v,$l) { $v = "" + $v; if ($v.length < $l) { for (var $i=0; $i<($l-$v.length); $i++) $v = "0" + $v; } return $v; } function getLang(a) { if (typeof(cal_text) == 'object') { switch (a) { case "day_short": case "day_long": case "months_short": case "months_long": { return cal_text[a]; }break; default: return "undef"; } } else { var $b; return typeof($b); } }