1
- const currentDateTimeText = document . getElementById ( ' currentDateTime' ) ;
2
- const currentDateTimeUtcText = document . getElementById ( ' currentDateTimeUtc' ) ;
3
- const currentProgressText = document . getElementById ( ' currentProgress' ) ;
1
+ const currentDateTimeText = document . getElementById ( " currentDateTime" ) ;
2
+ const currentDateTimeUtcText = document . getElementById ( " currentDateTimeUtc" ) ;
3
+ const currentProgressText = document . getElementById ( " currentProgress" ) ;
4
4
const currentDateTime = new Date ( ) ;
5
- const currentUtcDateTime = new Date ( currentDateTime . getUTCFullYear ( ) , currentDateTime . getUTCMonth ( ) , currentDateTime . getUTCDate ( ) , currentDateTime . getUTCHours ( ) , currentDateTime . getUTCMinutes ( ) , currentDateTime . getUTCSeconds ( ) ) ;
5
+ const currentUtcDateTime = new Date (
6
+ currentDateTime . getUTCFullYear ( ) ,
7
+ currentDateTime . getUTCMonth ( ) ,
8
+ currentDateTime . getUTCDate ( ) ,
9
+ currentDateTime . getUTCHours ( ) ,
10
+ currentDateTime . getUTCMinutes ( ) ,
11
+ currentDateTime . getUTCSeconds ( ) ,
12
+ ) ;
6
13
currentDateTimeText . textContent = `${ currentDateTime . toLocaleString ( ) } ` ;
7
14
currentDateTimeUtcText . textContent = `${ currentDateTime . toUTCString ( ) } ` ;
8
15
const currentYear = currentDateTime . getFullYear ( ) ;
@@ -34,27 +41,102 @@ const dayEnd = new Date(currentYear, currentMonth, currentDate + 1);
34
41
const dayStartUtc = new Date ( currentUtcYear , currentUtcMonth , currentUtcDate ) ;
35
42
const dayEndUtc = new Date ( currentUtcYear , currentUtcMonth , currentUtcDate + 1 ) ;
36
43
const hourStart = new Date ( currentYear , currentMonth , currentDate , currentHour ) ;
37
- const hourEnd = new Date ( currentYear , currentMonth , currentDate , currentHour + 1 ) ;
38
- const hourStartUtc = new Date ( currentUtcYear , currentUtcMonth , currentUtcDate , currentUtcHour ) ;
39
- const hourEndUtc = new Date ( currentUtcYear , currentUtcMonth , currentUtcDate , currentUtcHour + 1 ) ;
40
- const minuteStart = new Date ( currentYear , currentMonth , currentDate , currentHour , currentMinute ) ;
41
- const minuteEnd = new Date ( currentYear , currentMonth , currentDate , currentHour , currentMinute + 1 ) ;
42
- const minuteStartUtc = new Date ( currentUtcYear , currentUtcMonth , currentUtcDate , currentUtcHour , currentUtcMinute ) ;
43
- const minuteEndUtc = new Date ( currentUtcYear , currentUtcMonth , currentUtcDate , currentUtcHour , currentUtcMinute + 1 ) ;
44
- const secondStart = new Date ( currentYear , currentMonth , currentDate , currentHour , currentMinute , currentSecond ) ;
45
- const secondEnd = new Date ( currentYear , currentMonth , currentDate , currentHour , currentMinute , currentSecond + 1 ) ;
46
- const secondStartUtc = new Date ( currentUtcYear , currentUtcMonth , currentUtcDate , currentUtcHour , currentUtcMinute , currentUtcSecond ) ;
47
- const secondEndUtc = new Date ( currentUtcYear , currentUtcMonth , currentUtcDate , currentUtcHour , currentUtcMinute , currentUtcSecond + 1 ) ;
44
+ const hourEnd = new Date (
45
+ currentYear ,
46
+ currentMonth ,
47
+ currentDate ,
48
+ currentHour + 1 ,
49
+ ) ;
50
+ const hourStartUtc = new Date (
51
+ currentUtcYear ,
52
+ currentUtcMonth ,
53
+ currentUtcDate ,
54
+ currentUtcHour ,
55
+ ) ;
56
+ const hourEndUtc = new Date (
57
+ currentUtcYear ,
58
+ currentUtcMonth ,
59
+ currentUtcDate ,
60
+ currentUtcHour + 1 ,
61
+ ) ;
62
+ const minuteStart = new Date (
63
+ currentYear ,
64
+ currentMonth ,
65
+ currentDate ,
66
+ currentHour ,
67
+ currentMinute ,
68
+ ) ;
69
+ const minuteEnd = new Date (
70
+ currentYear ,
71
+ currentMonth ,
72
+ currentDate ,
73
+ currentHour ,
74
+ currentMinute + 1 ,
75
+ ) ;
76
+ const minuteStartUtc = new Date (
77
+ currentUtcYear ,
78
+ currentUtcMonth ,
79
+ currentUtcDate ,
80
+ currentUtcHour ,
81
+ currentUtcMinute ,
82
+ ) ;
83
+ const minuteEndUtc = new Date (
84
+ currentUtcYear ,
85
+ currentUtcMonth ,
86
+ currentUtcDate ,
87
+ currentUtcHour ,
88
+ currentUtcMinute + 1 ,
89
+ ) ;
90
+ const secondStart = new Date (
91
+ currentYear ,
92
+ currentMonth ,
93
+ currentDate ,
94
+ currentHour ,
95
+ currentMinute ,
96
+ currentSecond ,
97
+ ) ;
98
+ const secondEnd = new Date (
99
+ currentYear ,
100
+ currentMonth ,
101
+ currentDate ,
102
+ currentHour ,
103
+ currentMinute ,
104
+ currentSecond + 1 ,
105
+ ) ;
106
+ const secondStartUtc = new Date (
107
+ currentUtcYear ,
108
+ currentUtcMonth ,
109
+ currentUtcDate ,
110
+ currentUtcHour ,
111
+ currentUtcMinute ,
112
+ currentUtcSecond ,
113
+ ) ;
114
+ const secondEndUtc = new Date (
115
+ currentUtcYear ,
116
+ currentUtcMonth ,
117
+ currentUtcDate ,
118
+ currentUtcHour ,
119
+ currentUtcMinute ,
120
+ currentUtcSecond + 1 ,
121
+ ) ;
48
122
const yearProgress = ( currentDateTime - yearStart ) / ( yearEnd - yearStart ) ;
49
- const yearProgressUtc = ( currentUtcDateTime - yearStartUtc ) / ( yearEndUtc - yearStartUtc ) ;
123
+ const yearProgressUtc =
124
+ ( currentUtcDateTime - yearStartUtc ) / ( yearEndUtc - yearStartUtc ) ;
50
125
const monthProgress = ( currentDateTime - monthStart ) / ( monthEnd - monthStart ) ;
51
- const monthProgressUtc = ( currentUtcDateTime - monthStartUtc ) / ( monthEndUtc - monthStartUtc ) ;
126
+ const monthProgressUtc =
127
+ ( currentUtcDateTime - monthStartUtc ) / ( monthEndUtc - monthStartUtc ) ;
52
128
const dayProgress = ( currentDateTime - dayStart ) / ( dayEnd - dayStart ) ;
53
- const dayProgressUtc = ( currentUtcDateTime - dayStartUtc ) / ( dayEndUtc - dayStartUtc ) ;
129
+ const dayProgressUtc =
130
+ ( currentUtcDateTime - dayStartUtc ) / ( dayEndUtc - dayStartUtc ) ;
54
131
const hourProgress = ( currentDateTime - hourStart ) / ( hourEnd - hourStart ) ;
55
- const hourProgressUtc = ( currentUtcDateTime - hourStartUtc ) / ( hourEndUtc - hourStartUtc ) ;
56
- const minuteProgress = ( currentDateTime - minuteStart ) / ( minuteEnd - minuteStart ) ;
57
- const minuteProgressUtc = ( currentUtcDateTime - minuteStartUtc ) / ( minuteEndUtc - minuteStartUtc ) ;
58
- const secondProgress = ( currentDateTime - secondStart ) / ( secondEnd - secondStart ) ;
59
- const secondProgressUtc = ( currentUtcDateTime - secondStartUtc ) / ( secondEndUtc - secondStartUtc ) ;
60
- currentProgressText . textContent = ( `Year progress: ${ yearProgress } (${ yearProgressUtc } )\nMonth progress: ${ monthProgress } (${ monthProgressUtc } )\nDay progress: ${ dayProgress } (${ dayProgressUtc } )\nHour progress: ${ hourProgress } (${ hourProgressUtc } )\nMinute progress: ${ minuteProgress } (${ minuteProgressUtc } )\nSecond progress: ${ secondProgress } (${ secondProgressUtc } )` ) ;
132
+ const hourProgressUtc =
133
+ ( currentUtcDateTime - hourStartUtc ) / ( hourEndUtc - hourStartUtc ) ;
134
+ const minuteProgress =
135
+ ( currentDateTime - minuteStart ) / ( minuteEnd - minuteStart ) ;
136
+ const minuteProgressUtc =
137
+ ( currentUtcDateTime - minuteStartUtc ) / ( minuteEndUtc - minuteStartUtc ) ;
138
+ const secondProgress =
139
+ ( currentDateTime - secondStart ) / ( secondEnd - secondStart ) ;
140
+ const secondProgressUtc =
141
+ ( currentUtcDateTime - secondStartUtc ) / ( secondEndUtc - secondStartUtc ) ;
142
+ currentProgressText . textContent = `Year progress: ${ yearProgress } (${ yearProgressUtc } )\nMonth progress: ${ monthProgress } (${ monthProgressUtc } )\nDay progress: ${ dayProgress } (${ dayProgressUtc } )\nHour progress: ${ hourProgress } (${ hourProgressUtc } )\nMinute progress: ${ minuteProgress } (${ minuteProgressUtc } )\nSecond progress: ${ secondProgress } (${ secondProgressUtc } )` ;
0 commit comments