Skip to content

Commit

Permalink
Adjust dates on the client side to not use UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
ericlbarnes committed Jul 11, 2013
1 parent 93bfcb4 commit 24fbff5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/assets/coffee/config/jquery/dates.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ $.fn.formatDates = ->
originalDate = item.data("date")
if typeof format is "undefined"
format = "MMM Do YYYY, hh:mma"
time = if isNaN(originalDate) then moment.utc(originalDate, "YYYY-MM-DD HH:mm:ss") else moment.unix(originalDate)
time = if isNaN(originalDate) then moment(originalDate, "YYYY-MM-DD HH:mm:ss") else moment.unix(originalDate)
item.text time.local().format(format)
26 changes: 20 additions & 6 deletions public/admin/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ with (obj) {
__p += '<td class="title">\n <img src="" class="avatar img-polaroid" width="18" height="18">\n <a href="#" class="details">' +
((__t = ( title )) == null ? '' : __t) +
'</a>\n</td>\n<td class="status">' +
((__t = ( (active == 1) ? "Active" : "Draft" )) == null ? '' : __t) +
((__t = ( status() )) == null ? '' : __t) +
'</td>\n<td class="date js-format-date" data-date="' +
((__t = ( publish_date )) == null ? '' : __t) +
'">' +
Expand Down Expand Up @@ -167,7 +167,7 @@ $.fn.formatDates = function() {
if (typeof format === "undefined") {
format = "MMM Do YYYY, hh:mma";
}
time = isNaN(originalDate) ? moment.utc(originalDate, "YYYY-MM-DD HH:mm:ss") : moment.unix(originalDate);
time = isNaN(originalDate) ? moment(originalDate, "YYYY-MM-DD HH:mm:ss") : moment.unix(originalDate);
return item.text(time.local().format(format));
});
};
Expand Down Expand Up @@ -1821,16 +1821,30 @@ this.Wardrobe.module("PostApp.List", function(List, App, Backbone, Marionette, $
};

PostItem.prototype.onShow = function() {
var $avEl, user;
var $avEl, allUsers, user;
allUsers = App.request("get:all:users");
$avEl = this.$(".avatar");
user = this.model.get("user");
$avEl.avatar(user.email, $avEl.attr("width"));
return this.$('.js-format-date').formatDates();
if (allUsers.length === 1) {
return $avEl.hide();
} else {
user = this.model.get("user");
$avEl.avatar(user.email, $avEl.attr("width"));
return this.$('.js-format-date').formatDates();
}
};

PostItem.prototype.templateHelpers = {
previewUrl: function() {
return "" + (App.request("get:base:url")) + "/post/preview/" + this.id;
},
status: function() {
if (this.active === "1" && this.publish_date > moment().format('YYYY-MM-DD HH:mm:ss')) {
return "Scheduled";
} else if (this.active === "1") {
return "Active";
} else {
return "Draft";
}
}
};

Expand Down

0 comments on commit 24fbff5

Please sign in to comment.