Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stacks - Jackie - digital clock #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@ body {
background-color: #80d4ea;
}


#clock {
height: 100px;
width: 800px;
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
padding-top: 70px;
padding-top: 0px;
font-family: courier, monospace;
text-align: center;
color: white;
font-size: 100px;
}

#clock p{
font-size: 40px;
color: white;
text-align: center;
height: 100px;
width: auto;
margin: auto;
}
24 changes: 14 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>Clock Tower</title>
<meta charset="utf-8">
<link href="index.css" media="screen" rel="stylesheet" type="text/css"/>
</head>
<head>
<title>Clock Tower</title>
<meta charset="utf-8">
<link href="index.css" media="screen" rel="stylesheet" type="text/css"/>
</head>

<body>
<div id='clock'></div>
</body>
<body>
<div id='date'></div>
<div id='clock'></div>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>

<script src="index.js"></script>
96 changes: 96 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1 +1,97 @@
// Your code here
$(document).ready(function() {

var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

var getTime = function() {

var time = new Date();

var hour = ( time.getHours() > 12 ? (time.getHours() - 12) : time.getHours() );
var minute = ( time.getMinutes() < 10 ? "0" : "" ) + time.getMinutes();
var second = ('0' + time.getSeconds()).slice(-2);
var timeOfDay = ( time.getHours() >= 12 ? " PM" : " AM");

var div2 = $("#clock");

div2.html(hour + ":" + minute + ":" + second + timeOfDay);
// div.append(h1);
// div.append(hour, ":", minute, ":", second);
// div.append();

var d = new Date();
var dayOfWeek = days[d.getDay()];
var month = months[d.getMonth()];
var day = d.getDate();
var year = d.getFullYear();

var p = $("<p></p>");
p.html(dayOfWeek + ", " + month + " " + day + ", " + year);

div2.prepend(p);
// div2.html(p);

};

var interval = setInterval(function(){ getTime()}, 1000);

});

// var interval2 = setInterval(function() { getDate()}, 1000);


// var getDate = function() {
// var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
// var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
// var d = new Date();
// var dayOfWeek = days[d.getDay()];
// var month = months[d.getMonth()];
// var day = d.getDate();
// var year = d.getFullYear();
//
// var div1 = $("#date").html(dayOfWeek + ", " + month + " " + day + ", " + year);
// };
//
//
// function myTimer() {
// var d = new Date();
// var t = d.toLocaleTimeString();
// document.getElementById("demo").innerHTML = t;
// }

// console.log(time.hour);

// var h1 = $("<h1></h1>");
// // var hour = time.hour;
// // var minute = time.minute;
// // var second = time.second;
//
// // div.append(hour, minute, second);
//
//
// var h1 = $("<h1>" + time.hour + ":" + time.minute + ":" + time.second + "</h1>");
// div.append(h1);

// var h1 = $("<h1></h1>");
// var hour = time.hour;
// var minute = time.minute;
// var second = time.second;
//
// // div.append(h1);
//
// div.append(hour, ":", minute, ":", second);

// var intervalID = scope.setInterval(getTime(), 1000);

// var intervalID = time.setInterval(Clock, 1000);

// var Clock = function() {
// var currentDate = new Date();
// // this.hour = currentDate.getHours();
// // this.minute = currentDate.getMinutes();
// // this.second = currentDate.getSeconds();
// };


// var h1 = $("<h1></h1>");