Skip to content

Commit

Permalink
Issue #94 - Clock format toggling doesn't rotate through options as e…
Browse files Browse the repository at this point in the history
…xpected

- added variable 'local' to Clock
- updated toggleTimeFormat to use new 'local' var
- updated function tz in format.js to return 'Local Time' string
- updated test_clock.js to test toggling between local time
- added fsevents 1.2.4 to package.json
- updated package-lock.json to be insync with package.json
  • Loading branch information
aywaldron committed Nov 29, 2018
1 parent 70f28e5 commit 90df535
Show file tree
Hide file tree
Showing 5 changed files with 392 additions and 933 deletions.
6 changes: 4 additions & 2 deletions ait/gui/static/js/ait/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,13 @@ function time (obj, { h24 = true, gps = true, utc = false } = {}) {
}


function tz (obj, { utc = false, gps = true } = {}) {
function tz (obj, { utc = false, gps = true, local = false } = {}) {
if (gps) {
return 'GPS'
} else if (utc) {
return 'UTC'
return 'UTC'
} else if (local) {
return 'Local Time'
} else {
return timezone(obj)
}
Expand Down
27 changes: 18 additions & 9 deletions ait/gui/static/js/ait/gui/Clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const Clock =
_h24: true,
_utc: false,
_gps: true,
_local: false,
_doy: false,
_utc_gps_offset: 0,

Expand All @@ -65,12 +66,19 @@ const Clock =
if (this._gps) {
this._gps = false
this._utc = true
this._local = false
} else if (this._utc) {
this._gps = false
this._utc = false
this._local = true
} else if (this._local) {
this._gps = true
this._utc = false
this._local = false
} else {
this._gps = true
this._utc = false
this._local = false
}
},
toggleDOY() { this._doy = !this._doy },
Expand All @@ -87,10 +95,11 @@ const Clock =
this._utc_gps_offset = data[data.length - 1][1]
})

this._h24 = attrs.h24 !== undefined ? attrs.h24 : Clock._h24
this._utc = attrs.utc !== undefined ? attrs.utc : Clock._utc
this._gps = attrs.gps !== undefined ? attrs.gps : Clock._gps
this._doy = attrs.doy !== undefined ? attrs.doy : Clock._doy
this._h24 = attrs.h24 !== undefined ? attrs.h24 : Clock._h24
this._utc = attrs.utc !== undefined ? attrs.utc : Clock._utc
this._gps = attrs.gps !== undefined ? attrs.gps : Clock._gps
this._local = attrs.local !== undefined ? attrs.local : Clock._local
this._doy = attrs.doy !== undefined ? attrs.doy : Clock._doy
this.update()
},

Expand All @@ -102,10 +111,11 @@ const Clock =

view (vnode) {
const opts = {
doy: this._doy,
h24: this._h24,
utc: this._utc,
gps: this._gps,
doy: this._doy,
h24: this._h24,
utc: this._utc,
gps: this._gps,
local: this._local,
utc_gps_offset: this._utc_gps_offset
}

Expand All @@ -118,7 +128,6 @@ const Clock =
const time = format.time(datetime, opts)
const tz = format.tz (datetime, opts)


return m('ait-clock', vnode.attrs, [
m('span.date', { onclick: Clock.toggleDOY.bind(this) }, date), ' ',
m('span.time', { onclick: Clock.toggleH24.bind(this) }, time), ' ',
Expand Down
Loading

0 comments on commit 90df535

Please sign in to comment.