diff --git a/app/assets/javascripts/discourse/controllers/topic-entrance.js.es6 b/app/assets/javascripts/discourse/controllers/topic-entrance.js.es6 index 1a19dd442..26bb1e957 100644 --- a/app/assets/javascripts/discourse/controllers/topic-entrance.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic-entrance.js.es6 @@ -1,29 +1,46 @@ -function entranceDate(dt) { - var bumpedAt = new Date(dt), - today = new Date(); +function entranceDate(bumpedAt, showTime) { + var today = new Date(); if (bumpedAt.getDate() === today.getDate()) { return moment(bumpedAt).format(I18n.t("dates.time")); } if (bumpedAt.getYear() === today.getYear()) { - return moment(bumpedAt).format(I18n.t("dates.long_no_year")); + // No year + return moment(bumpedAt).format( + showTime ? I18n.t("dates.long_no_year") : I18n.t("dates.long_no_year_no_time") + ); } - return moment(bumpedAt).format(I18n.t('dates.long_with_year')); + return moment(bumpedAt).format( + showTime ? I18n.t('dates.long_with_year') : I18n.t('dates.long_with_year_no_time') + ); } export default Ember.ObjectController.extend({ position: null, - topDate: function() { - return entranceDate(this.get('created_at')); + createdDate: function() { + return new Date(this.get('model.created_at')); }.property('model.created_at'), - bottomDate: function() { - return entranceDate(this.get('bumped_at')); + bumpedDate: function() { + return new Date(this.get('model.bumped_at')); }.property('model.bumped_at'), + showTime: function() { + var diffMs = this.get('bumpedDate').getTime() - this.get('createdDate').getTime(); + return diffMs < (1000 * 60 * 60 * 24 * 2); + }.property('createdDate', 'bumpedDate'), + + topDate: function() { + return entranceDate(this.get('createdDate'), this.get('showTime')); + }.property('createdDate'), + + bottomDate: function() { + return entranceDate(this.get('bumpedDate'), this.get('showTime')); + }.property('bumpedDate'), + actions: { show: function(data) { // Show the chooser but only if the model changes diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 0cfa1b196..27e15d5c0 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -32,7 +32,9 @@ en: dates: time: "h:mm a" long_no_year: "MMM DD h:mm a" + long_no_year_no_time: "MMM DD" long_with_year: "MMM DD, YYYY h:mm a" + long_with_year_no_time: "MMM DD, YYYY" tiny: half_a_minute: "< 1m" less_than_x_seconds: