1
0
Fork 0

Now you can chose to display the timestamps in local time of the client

If you want to show times in UTC set useClientTimezone in config.js = 0 else
the timestamps and headers in the tables will be displayed in the local timezone
of the client-system. So if you are showing it in Japan with your local time there
you will get other results than showing it in New York.
main
Kim Huebel 4 years ago
parent 44c98a2f4e
commit ff474fa323

@ -92,7 +92,9 @@
<table id="lastHeard" class="table lastHeard table-condensed table-striped table-hover">
<thead>
<tr>
<th>Time (UTC)</th>
<th>Time (<script language="JavaScript">
document.write(getTimezone());
</script>)</th>
<th>Mode</th>
<th>Callsign</th>
<th>Target</th>
@ -129,7 +131,10 @@
<table id="localHeard" class="table localHeard table-condensed table-striped table-hover">
<thead>
<tr>
<th>Time (UTC)</th>
<th>Time (<script language="JavaScript">
document.write(getTimezone());
</script>)</th>
<th>Mode</th>
<th>Callsign</th>
<th>Target</th>
@ -155,8 +160,12 @@
<thead>
<tr>
<th>Callsign</th>
<th>Added at</th>
<th>Last TX at</th>
<th>Added at (<script language="JavaScript">
document.write(getTimezone());
</script>)</th>
<th>Last TX at (<script language="JavaScript">
document.write(getTimezone());
</script>)</th>
</tr>
</thead>
</table>
@ -175,7 +184,10 @@
<table id="dapnetmessages" class="table dapnetmessages table-condensed table-striped table-hover">
<thead>
<tr>
<th>Time (UTC)</th>
<th>Time (<script language="JavaScript">
document.write(getTimezone());
</script>)</th>
<th>Slot</th>
<th>RIC</th>
<th>Message</th>

@ -20,4 +20,7 @@ var showAboutTab = 1;
// default-tab to show
// chose from following list: CurrTXTab, LastHeardTab, LocalHeadTab, InQSOTab, DAPNETMessagesTab, SysInfoTab, AboutTab
var defaultTab = "LastHeardTab";
var defaultTab = "LastHeardTab";
// Set displayed timezone and timestamp to timezone of browser if 1, else use UTC for displaying
var useClientTimezone = 1;

@ -17,10 +17,52 @@ function logIt(message) {
}
}
function getTimestamp(logline) {
function getTimezone() {
if (useClientTimezone) {
var d = new Date();
var usertime = d.toLocaleString();
// Some browsers / OSs provide the timezone name in their local string:
var tzsregex = /\b(ACDT|ACST|ACT|ADT|AEDT|AEST|AFT|AKDT|AKST|AMST|AMT|ART|AST|AWDT|AWST|AZOST|AZT|BDT|BIOT|BIT|BOT|BRT|BST|BTT|CAT|CCT|CDT|CEDT|CEST|CET|CHADT|CHAST|CIST|CKT|CLST|CLT|COST|COT|CST|CT|CVT|CXT|CHST|DFT|EAST|EAT|ECT|EDT|EEDT|EEST|EET|EST|FJT|FKST|FKT|GALT|GET|GFT|GILT|GIT|GMT|GST|GYT|HADT|HAEC|HAST|HKT|HMT|HST|ICT|IDT|IRKT|IRST|IST|JST|KRAT|KST|LHST|LINT|MART|MAGT|MDT|MET|MEST|MIT|MSD|MSK|MST|MUT|MYT|NDT|NFT|NPT|NST|NT|NZDT|NZST|OMST|PDT|PETT|PHOT|PKT|PST|RET|SAMT|SAST|SBT|SCT|SGT|SLT|SST|TAHT|THA|UYST|UYT|VET|VLAT|WAT|WEDT|WEST|WET|WST|YAKT|YEKT)\b/gi;
// In other browsers the timezone needs to be estimated based on the offset:
var timezonenames = {"UTC+0":"GMT","UTC+1":"CET","UTC+2":"EET","UTC+3":"EEDT","UTC+3.5":"IRST","UTC+4":"MSD","UTC+4.5":"AFT","UTC+5":"PKT","UTC+5.5":"IST","UTC+6":"BST","UTC+6.5":"MST","UTC+7":"THA","UTC+8":"AWST","UTC+9":"AWDT","UTC+9.5":"ACST","UTC+10":"AEST","UTC+10.5":"ACDT","UTC+11":"AEDT","UTC+11.5":"NFT","UTC+12":"NZST","UTC-1":"AZOST","UTC-2":"GST","UTC-3":"BRT","UTC-3.5":"NST","UTC-4":"CLT","UTC-4.5":"VET","UTC-5":"EST","UTC-6":"CST","UTC-7":"MST","UTC-8":"PST","UTC-9":"AKST","UTC-9.5":"MIT","UTC-10":"HST","UTC-11":"SST","UTC-12":"BIT"};
var timezone = usertime.match(tzsregex);
if (timezone) {
timezone = timezone[timezone.length-1];
} else {
var offset = -1*d.getTimezoneOffset()/60;
offset = "UTC" + (offset >= 0 ? "+" + offset : offset);
timezone = timezonenames[offset];
}
return timezone;
} else {
return "UTC";
}
}
function getLocaltimeFromTimestamp(timestamp) {
logIt(timestamp);
if (useClientTimezone) {
var localtime = new Date(timestamp + "Z");
return localtime.toLocaleString();
} else {
return timestamp;
}
}
function getRawTimestamp(logline) {
return logline.substring(3,22);
}
function getTimestamp(logline) {
return getLocaltimeFromTimestamp(getRawTimestamp(logline));
}
function getMode(logline) {
return logline.substring(27, logline.indexOf(","));
}
@ -183,9 +225,10 @@ function leadingZero(zahl) {
function copyToQSO(callsign) {
$(document).ready(function() {
var date = new Date().toISOString().split('T')
t_qso.row.add( [
callsign,
new Date().toUTCString(),
getLocaltimeFromTimestamp(date[0] + " " + date[1].substring(0, date[1].indexOf("."))),
""
] ).draw();
});
@ -302,10 +345,10 @@ function getLastHeard(document, event) {
txing = true;
if (getMode(line) == "DMR Slot 1" ) {
ts1TXing = getMode(line) + ";" + line.substring(line.indexOf("from") + 5, line.indexOf("to")).trim() + ";" + getTarget(line) + ";" + getSource(line);
ts1timestamp = getTimestamp(line);
ts1timestamp = getRawTimestamp(line);
} else {
ts2TXing = getMode(line) + ";" + line.substring(line.indexOf("from") + 5, line.indexOf("to")).trim() + ";" + getTarget(line) + ";" + getSource(line);
ts2timestamp = getTimestamp(line);
ts2timestamp = getRawTimestamp(line);
}
}
if (line.indexOf("network watchdog") > 0 || line.indexOf("end of voice transmission") > 0 || line.indexOf("end of transmission") > 0) {

Loading…
Cancel
Save