Skip to content
Permalink
Browse files

Merge pull request #586 from lusbenjamin/bugfix-settings-log-date-parse

bugfix settings page log locale format ux
  • Loading branch information...
Manuel-777 committed Sep 19, 2019
2 parents 349fd3c + 55559d9 commit 3628e5a9d617c5977f5e4782735558a0a0f14549
Showing with 27 additions and 15 deletions.
  1. +1 −0 window_background/background-util.js
  2. +7 −1 window_background/background.js
  3. +19 −14 window_main/settings.js
@@ -159,6 +159,7 @@ function setData(data, refresh = debugLog || !firstPass) {
}

module.exports = {
getDateFormat,
ipc_send,
normaliseFields,
parseWotcTime,
@@ -46,6 +46,7 @@ const {
MAIN_DECKS
} = require("../shared/constants");
const {
getDateFormat,
ipc_send,
setData,
unleakString,
@@ -948,7 +949,12 @@ function onLogEntryFound(entry) {
default:
break;
}
setData({ last_log_timestamp: entry.timestamp });
if (entry.timestamp) {
setData({
last_log_timestamp: entry.timestamp,
last_log_format: getDateFormat(entry.timestamp)
});
}
} catch (err) {
console.log(entry.label, entry.position, entry.json());
console.error(err);
@@ -421,28 +421,33 @@ function appendArenaData(section) {
logFormatLabel.appendChild(logFormatCont);
section.appendChild(logFormatLabel);

const latestDateParsed = parse(
pd.last_log_timestamp,
pd.last_log_format,
new Date()
);
let parsedOutput = "auto-detection";
if (pd.settings.log_locale_format) {
const testDate = parse(
pd.last_log_timestamp,
pd.settings.log_locale_format,
new Date()
);
if (isValid(testDate) && !isNaN(testDate.getTime())) {
parsedOutput =
'<b class="green">' +
testDate.toISOString() +
"</b><i> (simplified extended ISO_8601 format)</i>";
} else {
parsedOutput = '<b class="red">Invalid format or timestamp</b>';
}
}
section.appendChild(
createDiv(
["settings_note"],
`<p><i>Date and time format to use when parsing the Arena log. Incorrect
`<p>Parsed output: ${parsedOutput}</p>
<p><i>Date and time format to use when parsing the Arena log. Incorrect
formats can cause issues importing or displaying data. mtgatool tries to
auto-detect formats, but sometimes manual input is required.</p>
<p>Leave blank to use default auto-detection, or
<a class="link parse_link">use ISO_8601 to specify a custom format</a>.</p></i>
<p>Last log timestamp: <b>${pd.last_log_timestamp}</b></p>
<p>Last format used: <b>${pd.last_log_format}</b></p>
<p>Parsed output: ${
isValid(latestDateParsed) && !isNaN(latestDateParsed.getTime())
? '<b class="green">' +
latestDateParsed.toISOString() +
"</b><i> (simplified extended ISO_8601 format)</i>"
: '<b class="red">Invalid format or timestamp</b>'
}</p>`
<p>Last format used: <b>${pd.last_log_format}</b></p>`
)
);

0 comments on commit 3628e5a

Please sign in to comment.
You can’t perform that action at this time.