This Python project simulates a fictional clock where the sun invariably rises at 6:00 AM and sets at 6:00 PM, regardless of the season. The duration of a second varies throughout the day and night to reflect seasonal changes while maintaining smooth, continuous variations with peaks at 12:00 PM and 12:00 AM.
- Simulates a fictional clock with:
- Fixed sunrise at 6:00 AM.
- Fixed sunset at 6:00 PM.
- Adjustable second durations to reflect seasonal changes.
- Smooth transitions between the dilation and contraction of seconds.
- Dynamic clock display using Streamlit with moving hands that update in real time.
- Docker (optional for containerized deployment)
- Python 3.11+ (if running without Docker)
- Required libraries (if using Python):
streamlitpandasnumpysuntimepytztimezonefinder
Run the Streamlit app to view the real-time fictional clock:
Install the dependencies using:
pip install -r requirements.txtRun the application:
streamlit run main.pyBuild the Docker image:
docker build -t fictional-clock .Run the container:
docker run -p 8501:8501 fictional-clockOpen your browser and navigate to http://localhost:8501 to access the application.
Core Functions
- Calculates the day and night durations based on the given date and latitude.
get_day_night_durations(date, latitude)- Computes the adjusted duration of a second at a given time, based on the current phase of the day or night.
second_duration(current_time, day_duration, night_duration, latitude, longitude)- Converts real-world time into the corresponding fictional time, accounting for the adjusted second durations.
get_fictif_hour(current_time, day_duration, night_duration, latitude, longitude)Streamlit Clock The application visualizes:
- A fictional clock with moving hands representing hours, minutes, and seconds.
- Dynamic second movements reflecting the adjusted durations.
from datetime import datetime
day_duration, night_duration = get_day_night_durations(datetime.now(), latitude=45)
print(f"Day Duration: {day_duration} hours, Night Duration: {night_duration} hours")current_time = datetime.now()
fictif_time = get_fictif_hour(current_time, day_duration, night_duration, latitude=45, longitude=3)
print(f"Fictional Time: {fictif_time}")📂 FictionalClock
├── 📄 main.py # Main Streamlit application
├── 📄 clock_logic.py # Core logic for time adjustments
├── 📄 requirements.txt # Python dependencies
└── 📄 README.md # Project documentation
└── 📄 Dockerfile # Dockerfile for containerized
Contributions are welcome! Feel free to open issues or submit pull requests for enhancements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.