This commit is contained in:
2025-08-26 14:59:49 -04:00
commit 29c24df1f5
3 changed files with 119 additions and 0 deletions

14
Dockerfile Normal file
View File

@@ -0,0 +1,14 @@
# Use an official Python runtime as a parent image
FROM python:3.9-slim
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy the current directory contents into the container at /usr/src/app
COPY . .
# Expose port 8080 for the HTTP server
EXPOSE 8080
# Run the application using Python's built-in HTTP server
CMD ["python3", "-m", "http.server", "8080"]

7
docker-compose.yml Normal file
View File

@@ -0,0 +1,7 @@
version: '3.8'
services:
personal-timezone:
build: .
ports:
- "8080:8080"

98
index.html Normal file
View File

@@ -0,0 +1,98 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Personal Timezone</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #121212;
color: #ffffff;
font-family: Arial, sans-serif;
margin: 0;
}
.container {
text-align: center;
}
h1 {
font-size: 2em;
margin-bottom: 0.5em;
}
h2 {
font-size: 1.5em;
margin: 0.5em 0;
}
.status {
margin-top: 1em;
font-size: 1em;
color: #ff5722;
}
</style>
</head>
<body>
<div class="container">
<h1>Personal Timezone</h1>
<h2 id="personal-time">Loading...</h2>
<div id="longitude"></div>
<div id="offset"></div>
<div class="status" id="status">Fetching location...</div>
</div>
<script>
(async function() {
try {
const statusElement = document.getElementById('status');
const longitudeElement = document.getElementById('longitude');
const offsetElement = document.getElementById('offset');
const personalTimeElement = document.getElementById('personal-time');
if (!navigator.geolocation) {
statusElement.textContent = 'Geolocation is not supported by your browser.';
return;
}
navigator.geolocation.getCurrentPosition(position => {
const { longitude } = position.coords;
const offset = longitude / 15;
longitudeElement.textContent = `Longitude: ${longitude.toFixed(2)}°`;
offsetElement.textContent = `Offset: ${offset.toFixed(2)} hours`;
statusElement.textContent = '';
function updateTime() {
const now = new Date();
const utcTime = new Date(now.getTime() + now.getTimezoneOffset() * 60000);
const personalTime = new Date(utcTime.getTime() + offset * 3600000);
personalTimeElement.textContent = personalTime.toISOString().substr(11, 8);
}
updateTime();
setInterval(updateTime, 1000);
}, error => {
let errorMessage = 'Unable to retrieve your location.';
switch(error.code) {
case error.PERMISSION_DENIED:
errorMessage = 'User denied the request for Geolocation.';
break;
case error.POSITION_UNAVAILABLE:
errorMessage = 'Location information is unavailable.';
break;
case error.TIMEOUT:
errorMessage = 'The request to get user location timed out.';
break;
case error.UNKNOWN_ERROR:
errorMessage = 'An unknown error occurred.';
break;
}
console.error('Geolocation error:', error);
statusElement.textContent = errorMessage;
});
} catch (error) {
document.getElementById('status').textContent = 'An error occurred: ' + error.message;
}
})();
</script>
</body>
</html>