Skip to content

Commit 107864b

Browse files
committed
Merge branch 'feat/ttl-calc' into chore/all-my-stuffs
# Conflicts: # components.d.ts # src/tools/index.ts
2 parents ee341e0 + b3d48c0 commit 107864b

File tree

4 files changed

+67
-1
lines changed

4 files changed

+67
-1
lines changed

pnpm-lock.yaml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tools/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ import { tool as rmbNumbers } from './rmb-numbers';
8787
import { tool as sensitiveDataMasker } from './sensitive-data-masker';
8888
import { tool as textToUnicodeNames } from './text-to-unicode-names';
8989
import { tool as torrentToMagnet } from './torrent-to-magnet';
90+
import { tool as ttlCalculator } from './ttl-calculator';
9091
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
9192
import { tool as numeronymGenerator } from './numeronym-generator';
9293
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -366,6 +367,8 @@ export const toolsByCategory: ToolCategory[] = [
366367
dataTransferRateConverter,
367368
dataStorageUnitConverter,
368369
],
370+
ttlCalculator,
371+
percentageCalculator],
369372
},
370373
{
371374
name: 'Measurement',

src/tools/ttl-calculator/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { CalendarTime } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'TTL calculator',
6+
path: '/ttl-calculator',
7+
description: 'TTL to Time converter',
8+
keywords: ['ttl', 'dns', 'calculator', 'time', 'live', 'duration'],
9+
component: () => import('./ttl-calculator.vue'),
10+
icon: CalendarTime,
11+
createdAt: new Date('2024-04-20'),
12+
});
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<script setup lang="ts">
2+
import { formatDuration, intervalToDuration } from 'date-fns';
3+
import SpanCopyable from '@/components/SpanCopyable.vue';
4+
5+
const days = ref(0);
6+
const hours = ref(24);
7+
const minutes = ref(0);
8+
const seconds = ref(0);
9+
const ttlDisplay = computed(() => (days.value * 86400 + hours.value * 3600 + minutes.value * 60 + seconds.value).toString());
10+
11+
const ttl = ref(0);
12+
const timeDisplay = computed(() => formatDuration(intervalToDuration({ start: 0, end: ttl.value * 1000 })));
13+
</script>
14+
15+
<template>
16+
<div>
17+
<c-card title="Time to TTL" mb-3>
18+
<n-space>
19+
<n-form-item label="Days">
20+
<n-input-number v-model:value="days" :min="0" />
21+
</n-form-item>
22+
<n-form-item label="Hours">
23+
<n-input-number v-model:value="hours" :min="0" />
24+
</n-form-item>
25+
<n-form-item label="Minutes">
26+
<n-input-number v-model:value="minutes" :min="0" />
27+
</n-form-item>
28+
<n-form-item label="Seconds">
29+
<n-input-number v-model:value="seconds" :min="0" />
30+
</n-form-item>
31+
</n-space>
32+
33+
<n-divider />
34+
35+
<n-form-item label="TTL:" label-placement="left">
36+
<SpanCopyable :value="ttlDisplay" />
37+
</n-form-item>
38+
</c-card>
39+
40+
<c-card title="TTL to Time">
41+
<n-form-item label="TTL">
42+
<n-input-number v-model:value="ttl" :min="0" />
43+
</n-form-item>
44+
45+
<n-divider />
46+
47+
<n-form-item label="Time">
48+
<SpanCopyable :value="timeDisplay" />
49+
</n-form-item>
50+
</c-card>
51+
</div>
52+
</template>

0 commit comments

Comments
 (0)