Browse Source

fix date in deadline tooltip not padding 9s.

main
Gisle Aune 4 years ago
parent
commit
01437c684f
  1. 9
      svelte-ui/src/components/DaysLeft.svelte

9
svelte-ui/src/components/DaysLeft.svelte

@ -1,4 +1,5 @@
<script lang="ts"> <script lang="ts">
import { formatDate } from "../utils/time";
import EveryMinute from "./EveryMinute.svelte"; import EveryMinute from "./EveryMinute.svelte";
export let startTime: Date | string = new Date(); export let startTime: Date | string = new Date();
@ -14,12 +15,6 @@
let titleTimeStr = ""; let titleTimeStr = "";
let now = new Date(); let now = new Date();
function formatTime(time: Date): string {
const pad = (n:number) => n < 9 ? '0'+n : n.toString();
return `${time.getFullYear()}-${pad(time.getMonth()+1)}-${pad(time.getDate())}`
}
$: { $: {
overdue = false; overdue = false;
unit = "days"; unit = "days";
@ -66,7 +61,7 @@
unit = unit.slice(0, 1); unit = unit.slice(0, 1);
} }
titleTimeStr = `${formatTime(new Date(startTime))} – ${formatTime(new Date(endTime))}`
titleTimeStr = `${formatDate(new Date(startTime))} – ${formatDate(new Date(endTime))}`
} }
</script> </script>

Loading…
Cancel
Save