Skip to content

Commit

Permalink
Merge pull request #11 from GeNiuS69/master
Browse files Browse the repository at this point in the history
add using locale
  • Loading branch information
b3by authored Dec 22, 2016
2 parents 65ad7c0 + 4094422 commit 8756451
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/atom-clock-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export default class AtomClockView {
this.refreshTicker()
}))

this.subscriptions.add(atom.config.onDidChange('atom-clock.locale', () => {
this.refreshTicker()
}))

this.subscriptions.add(atom.config.onDidChange('atom-clock.refreshInterval', () => {
this.refreshTicker()
}))
Expand All @@ -53,6 +57,7 @@ export default class AtomClockView {

setConfigValues() {
this.dateFormat = atom.config.get('atom-clock.dateFormat')
this.locale = atom.config.get('atom-clock.locale')
this.refreshInterval = atom.config.get('atom-clock.refreshInterval') * 1000
this.showIcon = atom.config.get('atom-clock.showClockIcon')
}
Expand All @@ -75,7 +80,7 @@ export default class AtomClockView {
}

setDate() {
this.date = Moment().format(this.dateFormat)
this.date = Moment().locale(this.locale).format(this.dateFormat)
this.element.firstChild.textContent = this.date
}

Expand Down
5 changes: 5 additions & 0 deletions lib/atom-clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export default {
title: 'Time format',
description: 'Specify the time format. Please take a look at http://momentjs.com/docs/#/displaying/format/ to check all the available formats.',
default: 'H:mm'
}, locale: {
type: 'string',
title: 'Locale',
description: 'Specify the time locale.',
default: 'en'
}, refreshInterval: {
type: 'integer',
title: 'Clock interval',
Expand Down
1 change: 1 addition & 0 deletions spec/atom-clock-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('Atom Clock', () => {
expect(AtomClock.atomClockView.element).toBeDefined()

expect(AtomClock.config.dateFormat.default).toBe('H:mm')
expect(AtomClock.config.locale.default).toBe('en')
expect(AtomClock.config.refreshInterval.default).toBe(60)
expect(AtomClock.config.showClockIcon.default).toBe(false)
})
Expand Down

0 comments on commit 8756451

Please sign in to comment.