import Ember from 'ember';
import moment from 'moment';

export default Ember.Component.extend({
  // TODO update time regularly

  classNames: ['component', 'clock'],
  timeFormat: '24h',

  formattedTime: function() {
    // TODO support 12h format
    let output = new moment().format('H:mm');

    return output;
  }.property(),

  formattedGreeting: function() {
    // TODO use name from config
    return `${this.get('greeting')}, ${this.get('name')}.` ;
  }.property('greeting'),

  greeting: function() {
    let greeting;

    if (moment().hour() < 12) {
      greeting = "Good morning";
    } else if (moment().hour() < 18) {
      greeting = "Good afternoon";
    } else {
      greeting = "Good evening";
    }

    return greeting;
  }.property(),

});

@@ -93,40 +93,8 @@
 nd(%7B
-%0A  // TODO update time regularly
 %0A%0A  
@@ -149,16 +149,162 @@
 : '24h',
+%0A  time: new moment(),%0A%0A  tick() %7B%0A    let self = this;%0A    this.set('time', new moment());%0A    setTimeout(function()%7B self.tick(); %7D, 2000);%0A  %7D,
 %0A%0A  form
@@ -433,24 +433,30 @@
  %7D.property(
+'time'
 ),%0A%0A  format
@@ -485,41 +485,8 @@
 ) %7B%0A
-    // TODO use name from config%0A
     
@@ -539,17 +539,16 @@
 ame')%7D.%60
- 
 ;%0A  %7D.pr
@@ -825,16 +825,16 @@
 eeting;%0A
-
   %7D.prop
@@ -842,12 +842,72 @@
 rty(),%0A%0A
+  startClock: function() %7B%0A    this.tick();%0A  %7D.on('init')%0A%0A
 %7D);%0A

Update clock every couple of seconds