2020// Started by using https://codepen.io/dudleystorey/pen/HLBki, but this has grown and changed quite a bit from there.
2121
2222import { getDayOfWeek , KsDateTime , KsTimeZone } from 'ks-date-time-zone' ;
23- import { isRaspbian } from './ util' ;
23+ import { isIE , isRaspbian , padLeft } from 'ks- util' ;
2424import { AppService } from './app.service' ;
25+ import * as $ from 'jquery' ;
2526
2627const SVC_NAMESPACE = 'http://www.w3.org/2000/svg' ;
2728
28- function pad ( n ) {
29- return ( n < 10 ? '0' : '' ) + n ;
30- }
31-
3229const daysOfWeek = [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] ;
3330const months = [ 'Jan' , 'Feb' , 'Mar' , 'Apr' , 'May' , 'Jun' , 'Jul' , 'Aug' , 'Sep' , 'Oct' , 'Nov' , 'Dec' ] ;
3431
@@ -62,7 +59,7 @@ export class Clock {
6259 private _hideSeconds = false ;
6360
6461 public timezone = KsTimeZone . OS_ZONE ;
65- public hasCompletingAnimation ;
62+ public hasCompletingAnimation = false ;
6663
6764 constructor ( private appService : AppService ) {
6865 this . secHand = document . getElementById ( 'sec-hand' ) ;
@@ -83,6 +80,9 @@ export class Clock {
8380 this . hasBeginElement = ! ! this . sweep . beginElement ;
8481
8582 this . decorateClockFace ( ) ;
83+
84+ if ( isIE ( ) )
85+ $ ( '#clock-container' ) . addClass ( 'clock-container-ie-fix' ) ;
8686 }
8787
8888 public start ( ) : void {
@@ -212,11 +212,11 @@ export class Clock {
212212 const animationTime = ( doMechanicalSecondHandEffect ? 200 : 0 ) ;
213213 const now = this . appService . getCurrentTime ( ) + animationTime ;
214214 const date = new KsDateTime ( now , this . timezone ) ;
215- const walltime = date . wallTime ;
216- const secs = walltime . sec ;
215+ const wallTime = date . wallTime ;
216+ const secs = wallTime . sec ;
217217 const secRotation = 6 * secs ;
218- const mins = walltime . min ;
219- const hour = walltime . hrs ;
218+ const mins = wallTime . min ;
219+ const hour = wallTime . hrs ;
220220
221221 if ( doMechanicalSecondHandEffect )
222222 sweepSecondHand ( this . lastSecRotation , secRotation ) ;
@@ -225,15 +225,15 @@ export class Clock {
225225 this . lastSecRotation = secRotation ;
226226 rotate ( this . minHand , 6 * mins + 0.1 * secs ) ;
227227 rotate ( this . hourHand , 30 * ( hour % 12 ) + mins / 2 + secs / 120 ) ;
228- setTimeout ( ( ) => this . tick ( ) , 1000 - walltime . millis ) ;
228+ setTimeout ( ( ) => this . tick ( ) , 1000 - wallTime . millis ) ;
229229
230230 setTimeout ( ( ) => {
231- const dayOfTheWeek = getDayOfWeek ( walltime . n ) ;
231+ const dayOfTheWeek = getDayOfWeek ( wallTime . n ) ;
232232
233233 this . dayOfWeekCaption . textContent = daysOfWeek [ dayOfTheWeek ] . toUpperCase ( ) ;
234- this . dateCaption . textContent = pad ( walltime . d ) ;
235- this . monthCaption . textContent = months [ walltime . m - 1 ] . toUpperCase ( ) ;
236- this . yearCaption . textContent = walltime . y . toString ( ) ;
234+ this . dateCaption . textContent = padLeft ( wallTime . d , 2 , '0' ) ;
235+ this . monthCaption . textContent = months [ wallTime . m - 1 ] . toUpperCase ( ) ;
236+ this . yearCaption . textContent = wallTime . y . toString ( ) ;
237237 this . day2Caption . textContent = daysOfWeek [ ( dayOfTheWeek + 2 ) % 7 ] ;
238238 this . day3Caption . textContent = daysOfWeek [ ( dayOfTheWeek + 3 ) % 7 ] ;
239239 this . zoneCaption . textContent = this . timezone . zoneName + ' UTC' + KsTimeZone . formatUtcOffset ( date . utcOffsetSeconds ) ;
@@ -251,8 +251,8 @@ export class Clock {
251251 }
252252
253253 this . timeCaption . textContent =
254- pad ( displayHour ) + ':' +
255- pad ( mins ) + ( this . _hideSeconds ? '' : ':' + pad ( secs ) ) + suffix ;
254+ padLeft ( displayHour , 2 , '0' ) + ':' +
255+ padLeft ( mins , 2 , '0' ) + ( this . _hideSeconds ? '' : ':' + padLeft ( secs , 2 , '0' ) ) + suffix ;
256256
257257 if ( mins !== this . lastMinute || this . lastTick + 60000 <= now ) {
258258 this . appService . updateTime ( hour , mins , this . lastMinute < 0 ) ;
0 commit comments