Skip to content

Commit

Permalink
(2.1.0 Release) Tweaks and some fixes
Browse files Browse the repository at this point in the history
- Swapped how the clock gets it's time from p5's default time function to JS's built in function for getting the time

- Removed the 0's before the numbers in the date as it felt unnecessary and weird

- Fixed the server not actually not using HTTPS when httpsMode is set to false.

- Changed how the server changes ports for httpsMode

- Removed unnecessary blank comment on the server
  • Loading branch information
AntsyBoi committed Oct 9, 2021
1 parent b5cf7dd commit 3ef0b5b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 32 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ if(httpsMode === true){
key: fs.readFileSync('key.key'), // Sets the location of the Private key
cert: fs.readFileSync('cert.pem') // Sets the location of the certificate
}; // If httpsMode is false, it sets sslOptions to state where the keys are located and allows use of them later on
https.createServer(sslOptions, app).listen(443, () => {
https.createServer(sslOptions, app).listen(port, () => {
console.log(`Time&Date listening at port ${port}`) // Outputs to the console that "Time&Date" (The name of the app) is listening to requests at a certain port
}) //
})
} else{ // End of HTTPS server, beginning of HTTP server
port = process.env.PORT || 80 // Redefines the default port
http.createServer(app).listen(443, () => { // Creates HTTP server
http.createServer(app).listen(port, () => { // Creates HTTP server
console.log(`Time&Date listening at http://localhost:${port}`) // Outputs to the console that "Time&Date" (The name of the app) is listening to requests at a certain port
}) // End of HTTP server
}
44 changes: 15 additions & 29 deletions src/timendate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,33 @@ function setup() {
function draw() {
resizeCanvas(windowWidth, windowHeight);
//Sets up variables so then they will display 0s when displaying
var preh = hour()
var m = minute()
var mo = month()
var s = second()
var d = day()
const Time = new Date();
var h = Time.getHours()
var m = Time.getMinutes()
var s = Time.getSeconds()
var mo = Time.getMonth()
var d = Time.getDay()
//Declares if they will have a 0 before the number
if (hour() > 12) {
preh = hour() - 12
if(Time.getHours() < 10){
h = "0" + Time.getHours()
}
var h = preh
if (preh < 10) {
h = "0" + preh
if(Time.getMinutes() < 10){
m = "0" + Time.getMinutes()
}

if (minute() < 10) {
m = "0" + minute()
if(Time.getSeconds() < 10){
s = "0" + Time.getSeconds()
}

if (month() < 10) {
mo = "0" + month()
}

if (second() < 10) {
s = "0" + second()
}

if (day() < 10) {
d = "0" + day()
}

//Global section
background(40) //Sets the background color for the project
fill(200) //Sets the color for all of the text.
//Time and date section
textSize(windowHeight / 7.976) //Defines size for the text of the time and date
textSize(windowHeight / 8) //Defines size for the text of the time and date
textAlign(CENTER, BOTTOM) //Aligns the text
text(h + ":" + m + ":" + s, 0, (windowHeight/2), width) //Displays the current time
textAlign(CENTER, BASELINE)
text(d + " / " + mo + " / " + year(), 0, (windowHeight/2), width) //Displays the current date
text(Time.getDay() + " / " + Time.getMonth() + " / " + Time.getFullYear(), 0, (windowHeight/2), width) //Displays the current date
//Timer section
textSize(windowHeight / 39.88) //Sizes the text for the timer part
textSize(windowHeight / 40) //Sizes the text for the timer part
textAlign(CENTER, BOTTOM); //Aligns the text for the counter part
//console.log(windowHeight + height)
text("To show you how much time you've spent, I have this timer " + ~~(millis() / 1000), 0, windowHeight, width) //Displays the timer
Expand Down

0 comments on commit 3ef0b5b

Please sign in to comment.