Skip to content

Commit

Permalink
refactor(l10n): parse datetime with built-in function
Browse files Browse the repository at this point in the history
Simplify date parsing. The date value is converted to ISO8601-like
format in UTC (Z) and parsed using built-in Date.parse().
  • Loading branch information
obradovichv committed Aug 17, 2021
1 parent c1d7c3c commit dccf5d4
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions locust/templates/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,7 @@ <h2>Charts</h2>
return currentContent;
}

let [date, time] = currentContent.split(" ");
let utcDateTime = new Date();
let [year, month, day] = date.split("-")
utcDateTime.setUTCFullYear(year, parseInt(month) - 1, day);
utcDateTime.setUTCHours(...(time.split(":")));

return utcDateTime.toLocaleString();
return new Date(Date.parse(currentContent.replace(" ", "T") + ".000Z")).toLocaleString();
});
</script>
</body>
Expand Down

0 comments on commit dccf5d4

Please sign in to comment.