@@ -30,11 +30,16 @@ class AnalogClock extends HTMLElement {
30
30
function drawClock ( ) {
31
31
getConfig ( ) ;
32
32
var now = new Date ( ) ;
33
- var options = '' ;
33
+ // var options = { timeZone: 'Europe/London', minute: 'numeric' },
34
34
if ( config . timezone ) { options = { timeZone : timezone } } ;
35
- var timestring = now . toLocaleString ( 'sv-SE' , options ) ;
36
- now = new Date ( timestring ) ;
37
- if ( demo ) now = new Date ( '2021-01-10 10:08:20' ) ;
35
+ var year = now . toLocaleString ( 'sv-SE' , { year : 'numeric' , timeZone : timezone } ) ;
36
+ var month = now . toLocaleString ( 'sv-SE' , { month : 'numeric' , timeZone : timezone } ) ;
37
+ var day = now . toLocaleString ( 'sv-SE' , { day : 'numeric' , timeZone : timezone } ) ;
38
+ var hour = now . toLocaleString ( 'sv-SE' , { hour : 'numeric' , timeZone : timezone } ) ;
39
+ var minute = now . toLocaleString ( 'sv-SE' , { minute : 'numeric' , timeZone : timezone } ) ;
40
+ var second = now . toLocaleString ( 'sv-SE' , { second : 'numeric' , timeZone : timezone } ) ;
41
+ now = new Date ( year , month , day , hour , minute , second ) ;
42
+ if ( demo ) now = new Date ( 2021 , 0 , 10 , 10 , 8 , 20 ) ;
38
43
drawFace ( ctx , radius , color_Background ) ;
39
44
drawTicks ( ctx , radius , color_Ticks ) ;
40
45
if ( ! hide_FaceDigits ) { drawFaceDigits ( ctx , radius , color_FaceDigits ) } ;
@@ -43,12 +48,12 @@ class AnalogClock extends HTMLElement {
43
48
if ( ! hide_WeekNumber ) { drawWeeknumber ( ctx , now , locale , radius , color_Text ) } ;
44
49
if ( ! hide_DigitalTime ) { drawTime ( ctx , now , locale , radius , color_DigitalTime , timezone ) } ;
45
50
var options = { hour : '2-digit' , hour12 : false } ;
46
- var hour = now . toLocaleTimeString ( "sv-SE" , options ) ;
51
+ hour = now . toLocaleTimeString ( "sv-SE" , options ) ;
47
52
options = { minute : '2-digit' , hour12 : false } ;
48
- var min = now . toLocaleTimeString ( "sv-SE" , options ) ;
53
+ minute = now . toLocaleTimeString ( "sv-SE" , options ) ;
49
54
// drawHandX(ctx, ang, length, width, color, style) ang in degrees
50
- drawHand ( ctx , ( Number ( hour ) + Number ( min ) / 60 ) * 30 , radius * 0.5 , radius / 20 , color_HourHand , style_HourHand ) ;
51
- drawHand ( ctx , ( Number ( min ) + now . getSeconds ( ) / 60 ) * 6 , radius * 0.8 , radius / 20 , color_MinuteHand , style_MinuteHand ) ;
55
+ drawHand ( ctx , ( Number ( hour ) + Number ( minute ) / 60 ) * 30 , radius * 0.5 , radius / 20 , color_HourHand , style_HourHand ) ;
56
+ drawHand ( ctx , ( Number ( minute ) + now . getSeconds ( ) / 60 ) * 6 , radius * 0.8 , radius / 20 , color_MinuteHand , style_MinuteHand ) ;
52
57
if ( ! hide_SecondHand ) { drawHand ( ctx , ( now . getSeconds ( ) ) * 6 , radius * 0.8 , 0 , color_SecondHand , style_SecondHand ) } ;
53
58
}
54
59
0 commit comments