Spaces:
Running
Running
Add 3 files
Browse files- README.md +7 -5
- index.html +194 -19
- prompts.txt +1 -0
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: time-calculator
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: yellow
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,194 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Time Calculator</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
9 |
+
<style>
|
10 |
+
.glow-text {
|
11 |
+
text-shadow: 0 0 10px rgba(59, 130, 246, 0.7);
|
12 |
+
}
|
13 |
+
.input-field {
|
14 |
+
transition: all 0.3s ease;
|
15 |
+
}
|
16 |
+
.input-field:focus {
|
17 |
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
|
18 |
+
}
|
19 |
+
.result-box {
|
20 |
+
background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(129, 140, 248, 0.1) 100%);
|
21 |
+
backdrop-filter: blur(5px);
|
22 |
+
}
|
23 |
+
.clock-digit {
|
24 |
+
font-family: 'Courier New', monospace;
|
25 |
+
font-weight: bold;
|
26 |
+
}
|
27 |
+
</style>
|
28 |
+
</head>
|
29 |
+
<body class="bg-gray-900 text-white min-h-screen flex flex-col items-center justify-center p-4">
|
30 |
+
<div class="max-w-2xl w-full bg-gray-800 rounded-xl shadow-2xl overflow-hidden">
|
31 |
+
<!-- Header -->
|
32 |
+
<div class="bg-blue-600 p-6 text-center">
|
33 |
+
<h1 class="text-3xl font-bold glow-text">Time Calculator</h1>
|
34 |
+
<p class="mt-2 text-blue-100">Calculate future dates based on time duration</p>
|
35 |
+
</div>
|
36 |
+
|
37 |
+
<!-- Current Time Display -->
|
38 |
+
<div class="p-6 border-b border-gray-700">
|
39 |
+
<div class="flex justify-center items-center space-x-4">
|
40 |
+
<i class="fas fa-clock text-blue-400 text-2xl"></i>
|
41 |
+
<div id="current-time" class="text-2xl font-mono clock-digit">00:00:00</div>
|
42 |
+
<div id="current-date" class="text-gray-300">-</div>
|
43 |
+
</div>
|
44 |
+
</div>
|
45 |
+
|
46 |
+
<!-- Input Section -->
|
47 |
+
<div class="p-6">
|
48 |
+
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-6">
|
49 |
+
<div>
|
50 |
+
<label for="days" class="block text-sm font-medium text-gray-300 mb-1">Days</label>
|
51 |
+
<input type="number" id="days" class="w-full input-field bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 focus:outline-none focus:border-blue-500" min="0" value="0">
|
52 |
+
</div>
|
53 |
+
<div>
|
54 |
+
<label for="hours" class="block text-sm font-medium text-gray-300 mb-1">Hours</label>
|
55 |
+
<input type="number" id="hours" class="w-full input-field bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 focus:outline-none focus:border-blue-500" min="0" max="23" value="0">
|
56 |
+
</div>
|
57 |
+
<div>
|
58 |
+
<label for="minutes" class="block text-sm font-medium text-gray-300 mb-1">Minutes</label>
|
59 |
+
<input type="number" id="minutes" class="w-full input-field bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 focus:outline-none focus:border-blue-500" min="0" max="59" value="0">
|
60 |
+
</div>
|
61 |
+
<div>
|
62 |
+
<label for="seconds" class="block text-sm font-medium text-gray-300 mb-1">Seconds</label>
|
63 |
+
<input type="number" id="seconds" class="w-full input-field bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 focus:outline-none focus:border-blue-500" min="0" max="59" value="0">
|
64 |
+
</div>
|
65 |
+
</div>
|
66 |
+
|
67 |
+
<button id="calculate-btn" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-lg transition duration-300 flex items-center justify-center space-x-2">
|
68 |
+
<i class="fas fa-calculator"></i>
|
69 |
+
<span>Calculate Future Time</span>
|
70 |
+
</button>
|
71 |
+
</div>
|
72 |
+
|
73 |
+
<!-- Result Section -->
|
74 |
+
<div id="result-section" class="p-6 hidden">
|
75 |
+
<div class="result-box border border-blue-500 rounded-lg p-4">
|
76 |
+
<h3 class="text-lg font-semibold text-blue-400 mb-2">Result:</h3>
|
77 |
+
<p id="result-text" class="text-gray-200"></p>
|
78 |
+
</div>
|
79 |
+
</div>
|
80 |
+
|
81 |
+
<!-- Instructions -->
|
82 |
+
<div class="bg-gray-700 p-4 text-sm text-gray-300">
|
83 |
+
<div class="flex items-start space-x-2">
|
84 |
+
<i class="fas fa-info-circle text-blue-400 mt-1"></i>
|
85 |
+
<div>
|
86 |
+
<p class="font-medium">How to use:</p>
|
87 |
+
<p class="mt-1">Enter days, hours, minutes and seconds, then click "Calculate" to see what the date and time will be after that duration from now.</p>
|
88 |
+
</div>
|
89 |
+
</div>
|
90 |
+
</div>
|
91 |
+
</div>
|
92 |
+
|
93 |
+
<script>
|
94 |
+
// Update current time every second
|
95 |
+
function updateCurrentTime() {
|
96 |
+
const now = new Date();
|
97 |
+
const timeElement = document.getElementById('current-time');
|
98 |
+
const dateElement = document.getElementById('current-date');
|
99 |
+
|
100 |
+
// Format time (HH:MM:SS)
|
101 |
+
const hours = String(now.getHours()).padStart(2, '0');
|
102 |
+
const minutes = String(now.getMinutes()).padStart(2, '0');
|
103 |
+
const seconds = String(now.getSeconds()).padStart(2, '0');
|
104 |
+
timeElement.textContent = `${hours}:${minutes}:${seconds}`;
|
105 |
+
|
106 |
+
// Format date (Month Day, Year)
|
107 |
+
const options = { year: 'numeric', month: 'long', day: 'numeric' };
|
108 |
+
dateElement.textContent = now.toLocaleDateString(undefined, options);
|
109 |
+
}
|
110 |
+
|
111 |
+
// Initialize and update time every second
|
112 |
+
updateCurrentTime();
|
113 |
+
setInterval(updateCurrentTime, 1000);
|
114 |
+
|
115 |
+
// Calculate future time
|
116 |
+
document.getElementById('calculate-btn').addEventListener('click', function() {
|
117 |
+
// Get input values
|
118 |
+
const days = parseInt(document.getElementById('days').value) || 0;
|
119 |
+
const hours = parseInt(document.getElementById('hours').value) || 0;
|
120 |
+
const minutes = parseInt(document.getElementById('minutes').value) || 0;
|
121 |
+
const seconds = parseInt(document.getElementById('seconds').value) || 0;
|
122 |
+
|
123 |
+
// Validate inputs
|
124 |
+
if (days < 0 || hours < 0 || minutes < 0 || seconds < 0) {
|
125 |
+
alert("Please enter positive numbers only");
|
126 |
+
return;
|
127 |
+
}
|
128 |
+
|
129 |
+
if (hours > 23 || minutes > 59 || seconds > 59) {
|
130 |
+
alert("Please enter valid time values (hours: 0-23, minutes: 0-59, seconds: 0-59)");
|
131 |
+
return;
|
132 |
+
}
|
133 |
+
|
134 |
+
// Calculate future date
|
135 |
+
const now = new Date();
|
136 |
+
const futureDate = new Date(now);
|
137 |
+
|
138 |
+
// Add the input duration to current date
|
139 |
+
futureDate.setDate(futureDate.getDate() + days);
|
140 |
+
futureDate.setHours(futureDate.getHours() + hours);
|
141 |
+
futureDate.setMinutes(futureDate.getMinutes() + minutes);
|
142 |
+
futureDate.setSeconds(futureDate.getSeconds() + seconds);
|
143 |
+
|
144 |
+
// Format the result string
|
145 |
+
const options = {
|
146 |
+
year: 'numeric',
|
147 |
+
month: 'long',
|
148 |
+
day: 'numeric',
|
149 |
+
hour: 'numeric',
|
150 |
+
minute: '2-digit',
|
151 |
+
second: '2-digit',
|
152 |
+
hour12: true
|
153 |
+
};
|
154 |
+
const formattedDate = futureDate.toLocaleDateString(undefined, options);
|
155 |
+
|
156 |
+
// Build the result text
|
157 |
+
let durationText = [];
|
158 |
+
if (days > 0) durationText.push(`${days} day${days !== 1 ? 's' : ''}`);
|
159 |
+
if (hours > 0) durationText.push(`${hours} hour${hours !== 1 ? 's' : ''}`);
|
160 |
+
if (minutes > 0) durationText.push(`${minutes} minute${minutes !== 1 ? 's' : ''}`);
|
161 |
+
if (seconds > 0) durationText.push(`${seconds} second${seconds !== 1 ? 's' : ''}`);
|
162 |
+
|
163 |
+
if (durationText.length === 0) {
|
164 |
+
durationText = ["0 seconds"];
|
165 |
+
}
|
166 |
+
|
167 |
+
const resultText = `In ${durationText.join(', ')} from now it will be ${formattedDate}.`;
|
168 |
+
|
169 |
+
// Display the result
|
170 |
+
document.getElementById('result-text').textContent = resultText;
|
171 |
+
document.getElementById('result-section').classList.remove('hidden');
|
172 |
+
|
173 |
+
// Scroll to result
|
174 |
+
document.getElementById('result-section').scrollIntoView({ behavior: 'smooth' });
|
175 |
+
});
|
176 |
+
|
177 |
+
// Add input validation
|
178 |
+
document.getElementById('hours').addEventListener('change', function() {
|
179 |
+
if (this.value > 23) this.value = 23;
|
180 |
+
if (this.value < 0) this.value = 0;
|
181 |
+
});
|
182 |
+
|
183 |
+
document.getElementById('minutes').addEventListener('change', function() {
|
184 |
+
if (this.value > 59) this.value = 59;
|
185 |
+
if (this.value < 0) this.value = 0;
|
186 |
+
});
|
187 |
+
|
188 |
+
document.getElementById('seconds').addEventListener('change', function() {
|
189 |
+
if (this.value > 59) this.value = 59;
|
190 |
+
if (this.value < 0) this.value = 0;
|
191 |
+
});
|
192 |
+
</script>
|
193 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=fenglui/time-calculator" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
194 |
+
</html>
|
prompts.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Make a time calculator Interface Display the current time ticking away, updating every second like a clock Input fields for days, hours, minutes and seconds Enter button Details Enter your data and press enter to calculate when the time will be. Example User enters 4 days, 17 hours, 12 minutes and 0 seconds and presses enter. The screen will display “In 4 days, 17 hours, 12 minutes and 0 seconds from now it will be October 7, 2015 at 3:14:08 AM.”
|