From d61d68e4fb71f23cc2c08742126cb71b2aa7fd0c Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Thu, 11 Sep 2025 12:57:22 +0000 Subject: [PATCH 1/2] fix: enhance Unix timestamp converter with current time initialization, timezone display, and time adjustment buttons - Initialize with current time instead of hardcoded date (2025-01-12) - Add timezone display next to local time (e.g., America/New_York) - Add +/- buttons for adjusting time by seconds, minutes, hours, and days - Implement adjustTime() function that works with all timestamp formats - Maintains existing auto-detection and format conversion functionality Fixes #20 Co-authored-by: Gordon Weakliem --- pages/utils/timestamp.vue | 76 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 3 deletions(-) diff --git a/pages/utils/timestamp.vue b/pages/utils/timestamp.vue index cd22a9a..6b9ea78 100644 --- a/pages/utils/timestamp.vue +++ b/pages/utils/timestamp.vue @@ -28,6 +28,47 @@ + + +
+ +
+ +
+ Seconds +
+ + +
+
+ +
+ Minutes +
+ + +
+
+ +
+ Hours +
+ + +
+
+ +
+ Days +
+ + +
+
+
+
@@ -98,14 +139,14 @@ const timestampFormat = ref('seconds') // Initialize with current time - const now = new Date('2025-01-12T08:53:55-07:00') + const now = new Date() dateTime.value = now.toISOString().slice(0, 16) timestamp.value = Math.floor(now.getTime() / 1000).toString() const detectFormat = (value: string): string => { if (!value) return 'seconds' const num = parseFloat(value) - const now = new Date('2025-01-12T08:53:55-07:00').getTime() + const now = new Date().getTime() const maxEpoch = 2147483647; // 2^31-1, max representable seconds // Reasonable ranges for each format based on current time @@ -201,6 +242,32 @@ } } } + + const adjustTime = (amount: number, unit: 'seconds' | 'minutes' | 'hours' | 'days') => { + if (!timestamp.value) return + + const ms = getMillisecondsFromTimestamp(timestamp.value, timestampFormat.value) + const date = new Date(ms) + + switch (unit) { + case 'seconds': + date.setSeconds(date.getSeconds() + amount) + break + case 'minutes': + date.setMinutes(date.getMinutes() + amount) + break + case 'hours': + date.setHours(date.getHours() + amount) + break + case 'days': + date.setDate(date.getDate() + amount) + break + } + + const newMs = date.getTime() + timestamp.value = convertTimestampToFormat(newMs, timestampFormat.value) + dateTime.value = date.toISOString().slice(0, 16) + } const allFormats = computed(() => { if (!timestamp.value) { @@ -224,7 +291,10 @@ const formattedLocalTime = computed(() => { if (!timestamp.value) return '-' const ms = getMillisecondsFromTimestamp(timestamp.value, timestampFormat.value) - return new Date(ms).toLocaleString() + const date = new Date(ms) + const timeString = date.toLocaleString() + const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone + return `${timeString} (${timezone})` }) const formattedUTCTime = computed(() => { From b2e6c6711911243ebb618862be2511dc0dc0ee60 Mon Sep 17 00:00:00 2001 From: Gordon Weakliem Date: Thu, 11 Sep 2025 08:55:17 -0600 Subject: [PATCH 2/2] Implement up/down arrows instead of text, line up layout --- pages/utils/timestamp.vue | 40 +++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/pages/utils/timestamp.vue b/pages/utils/timestamp.vue index 6b9ea78..212a6c3 100644 --- a/pages/utils/timestamp.vue +++ b/pages/utils/timestamp.vue @@ -37,34 +37,50 @@
- Seconds
- - + + Seconds +
- Minutes
- - + + Minutes +
- Hours
- - + + Hours +
- Days
- - + + Days +