Skip to content

Commit 1f6451c

Browse files
authored
Merge pull request #5 from GauriShirke12/digitclock
Digita-Clock project
2 parents 5d2366d + bca6d13 commit 1f6451c

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed

DigitalClock/CONTRIBUTING.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Contributing to Digital Clock
2+
3+
Thank you for your interest in contributing!
4+
This is a beginner-friendly project, so contributions are always welcome.
5+
6+
## Ways You Can Contribute
7+
8+
- Add new features (e.g., show date, dark/light mode, alarm function).
9+
- Improve the design or styling (colors, fonts, layout).
10+
- Refactor code to make it cleaner or easier to understand.
11+
- Add more detailed comments or explanations for beginners.
12+
- Fix bugs or errors.
13+
- Make the clock **responsive** so it works well on mobile devices.
14+
- Add **sound notifications or chimes** for each hour.
15+
- Include **customizable themes** (users can pick colors or styles).
16+
- Create **additional versions** (12-hour vs 24-hour format).
17+
- Write a **step-by-step tutorial** or documentation for beginners.
18+
- Add **accessibility features** (e.g., readable text, screen reader support).
19+
- Optimize performance (ensure the clock runs smoothly and is lightweight).
20+
21+
## Steps to Contribute
22+
1. **Fork the repository** and clone it locally.
23+
2. Navigate to `JavaScript/DigitalClock/`.
24+
3. Create a new branch for your feature or fix:
25+
```bash
26+
git checkout -b feature-name
27+
28+
29+
## Pull Request Review Process
30+
31+
1. **Automatic Checks**
32+
- CI/CD will run tests and lints on your PR.
33+
- Make sure all checks pass.
34+
35+
2. **Review**
36+
- A maintainer will review your PR for code quality, functionality, and adherence to guidelines.
37+
- You may be asked to make changes—please respond promptly.
38+
39+
3. **Merge**
40+
- Once approved and all checks pass, your PR will be merged.
41+
- You’ll be credited in the project’s contributors list!
42+

DigitalClock/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Digital Clock
2+
3+
A beginner-friendly JavaScript project to display a live digital clock in the browser.
4+
5+
## Features
6+
- Shows current time in 12-hour format with AM/PM.
7+
- Stylish and easy to understand.
8+
- Can be extended (add date, dark mode, alarms, etc.)
9+
10+
## How to Run
11+
1. Open `digital_clock.html` in your browser.
12+
2. Clock updates automatically every second.
13+
14+
## Contribution
15+
See `CONTRIBUTING.md` for how to add features or improve this project.

DigitalClock/digital_clock.html

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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>Digital Clock</title>
7+
<style>
8+
/* Center the clock on the page with a nice design */
9+
body {
10+
display: flex;
11+
justify-content: center;
12+
align-items: center;
13+
height: 100vh; /* full viewport height */
14+
background: #111; /* dark background */
15+
color: #00ffcc; /* neon green text */
16+
font-family: monospace, Arial, sans-serif;
17+
font-size: 3rem;
18+
}
19+
20+
/* Style the clock container */
21+
#clock {
22+
padding: 20px;
23+
border: 2px solid #00ffcc;
24+
border-radius: 10px;
25+
box-shadow: 0 0 15px #00ffcc;
26+
}
27+
</style>
28+
</head>
29+
<body>
30+
<!-- The clock will appear inside this div -->
31+
<div id="clock"></div>
32+
33+
34+
<script>
35+
// Function to update the clock every second
36+
function updateClock() {
37+
const now = new Date(); // get current date and time
38+
39+
// Get hours, minutes, and seconds
40+
let hours = now.getHours();
41+
let minutes = now.getMinutes();
42+
let seconds = now.getSeconds();
43+
44+
// Determine AM or PM
45+
const ampm = hours >= 12 ? 'PM' : 'AM';
46+
47+
// Convert 24-hour format to 12-hour format
48+
hours = hours % 12 || 12; // if hours = 0, set to 12
49+
50+
// Add leading zeros to minutes and seconds if needed
51+
minutes = minutes < 10 ? '0' + minutes : minutes;
52+
seconds = seconds < 10 ? '0' + seconds : seconds;
53+
54+
// Format the time string
55+
const timeString = `${hours}:${minutes}:${seconds} ${ampm}`;
56+
57+
// Display the time in the clock div
58+
document.getElementById('clock').textContent = timeString;
59+
}
60+
61+
// Call updateClock every 1000 milliseconds (1 second)
62+
setInterval(updateClock, 1000);
63+
64+
// Call it once immediately to show the clock right away
65+
updateClock();
66+
</script>
67+
</body>
68+
</html>

0 commit comments

Comments
 (0)