Skip to content

Commit

Permalink
circuit-sim minor: use new dateToString util
Browse files Browse the repository at this point in the history
  • Loading branch information
clbarnes committed Dec 20, 2021
1 parent 3bf0ca5 commit 27cad8b
Showing 1 changed file with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,6 @@
(function (CATMAID) {
"use strict";

function padNum(n, len) {
return n.toString().padStart(len, "0");
}

function timeString() {
const now = new Date();
const year = padNum(now.getFullYear(), 4);
const mon = padNum(now.getMonth() + 1, 2);
const day = padNum(now.getDate(), 2);
const hour = padNum(now.getHours(), 2);
const min = padNum(now.getMinutes(), 2);
return `${year}-${mon}-${day}T${hour}${min}`;
}

function zip(arrays) {
const minLen = arrays.reduce(
(accum, curr) => Math.min(accum, curr.length),
Expand Down Expand Up @@ -137,7 +123,8 @@
rates: zip(this.sol.y),
};

const defaultFilename = `circuit-simulation_${timeString()}.json`;
const timestamp = CATMAID.tools.dateToString(null, "T", "");
const defaultFilename = `circuit-simulation_${timestamp}.json`;
saveAs(
new Blob([JSON.stringify(out, null, " ")], {
type: "application/json",
Expand Down

0 comments on commit 27cad8b

Please sign in to comment.