Skip to content

Commit 61a1d08

Browse files
committed
Fix time
1 parent ec8db8a commit 61a1d08

File tree

4 files changed

+31
-42
lines changed

4 files changed

+31
-42
lines changed

web/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<meta name="keywords" content="Forza Horizon, Forza Horizon 4, Forza Horizon 4 seasons, Forza Horizon 4 weekly season change,
77
FH4 seasons, Forza Horizon 4 calendar, FH4 season tracker">
88
<meta name="viewport" content="width=device-width, initial-scale=1.0">
9-
<link rel="manifest" href="manifest.json">
109
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Asap+Condensed">
1110
<link rel="shortcut icon" href="images/fh4_icon.png" type="image/x-icon">
1211
<link rel="stylesheet" href="styles.css">

web/manifest.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

web/scripts.js

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,24 @@
11
function getTime() {
2-
let baseDate = new Date("2025-02-13"); // dia base
2+
const BASEDATE = new Date(Date.UTC(2025, 1, 13, 14, 30)); // 2025-02-13 14:30 en UTC, los meses en UTC empiezan en cero!!!
33
let now = new Date();
4-
let timeDifference = Math.floor((now.getTime() - baseDate.getTime()) / 60 / 60 / 24 / 1000);
5-
let eachWeek = Math.floor(timeDifference / 7);
6-
let result = eachWeek % 4;
4+
let utcTimestamp = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(),
5+
now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds()); // el UTC de la hora actual
6+
7+
let timeDifference = Math.floor((utcTimestamp - BASEDATE.getTime()) / 60 / 1000);
8+
let eachWeek = Math.floor(timeDifference / 10080); // 7 dias en minutos
79

8-
return {result, now};
10+
let result = eachWeek % 4;
11+
return result;
912
}
1013

1114
function setSeason() {
15+
const SEASONS = {0:"autumn", 1:"winter", 2:"spring", 3:"summer"};
1216
let season = document.getElementById("season");
13-
let {result, now} = getTime();
14-
15-
let weekDay = now.getUTCDay();
16-
let nowHour = now.getUTCHours();
17-
let nowMinutes = now.getUTCMinutes();
18-
let nowHourMinutes = nowHour * 60 + nowMinutes;
19-
20-
// 870 minutos son las 14:30
21-
if ((nowHourMinutes >= 870) && (weekDay == 4)) {
22-
result++;
23-
result = result % 4;
24-
}
25-
26-
switch (result) {
27-
case 0:
28-
season.textContent = "It's autumn!";
29-
document.title = "It's autumn in FH4!"
30-
break;
31-
case 1:
32-
season.textContent = "It's winter!";
33-
document.title = "It's winter in FH4!"
34-
break;
35-
case 2:
36-
season.textContent = "It's spring!";
37-
document.title = "It's spring in FH4!"
38-
break;
39-
case 3:
40-
season.textContent = "It's summer!";
41-
document.title = "It's summer in FH4!"
42-
break;
43-
}
17+
let result = getTime();
4418

45-
document.body.style.backgroundImage = `url(images/${result}.jpg)`
19+
season.textContent = `It's ${SEASONS[result]}`;
20+
document.title = `It's ${SEASONS[result]} in FH4!`;
21+
document.body.style.backgroundImage = `url(images/${result}.jpg)`;
4622
}
4723

4824
setSeason();

web/styles.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
}
66

77
body {
8+
background: #E4704B;
9+
background: linear-gradient(to right, #E4704B 0%, #CA347E 100%);
810
display: flex;
911
align-items: center;
1012
justify-content: center;
@@ -52,4 +54,20 @@ body {
5254
bottom: 0;
5355
max-width: 5%;
5456
max-height: 5%;
57+
}
58+
59+
@media screen and (width <= 950px) and (orientation: portrait){
60+
body {
61+
background-position: bottom right -200px;
62+
}
63+
#content {
64+
height: 40%;
65+
width: 40%;
66+
}
67+
#season {
68+
font-size: 7vw;
69+
}
70+
#when {
71+
font-size: 4vw;
72+
}
5573
}

0 commit comments

Comments
 (0)