From d67a492b6c8c19a602abb43c1232610b6dcd780c Mon Sep 17 00:00:00 2001 From: William Kim Date: Mon, 12 Aug 2013 14:26:16 -0400 Subject: [PATCH] date display logic to use moment.js. --- .../src/main/webapp/resources/js/grant.js | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/openid-connect-server/src/main/webapp/resources/js/grant.js b/openid-connect-server/src/main/webapp/resources/js/grant.js index 513f0fd8a..aa6cd1fc9 100644 --- a/openid-connect-server/src/main/webapp/resources/js/grant.js +++ b/openid-connect-server/src/main/webapp/resources/js/grant.js @@ -118,9 +118,24 @@ var ApprovedSiteView = Backbone.View.extend({ render: function() { - var formattedDate = {creationDate: moment(this.model.creationDate).format("ddd, hA"), - accessDate: moment(this.model.accessDate), - timeoutDate: moment(this.model.timeoutDate)}; + var creationDate = moment(this.model.get("creationDate")); + var accessDate = moment(this.model.get("accessDate")); + + var timeoutDate = moment(this.model.get("timeoutDate")).calendar(); + + if (moment().diff(creationDate, 'months') < 6) { + creationDate = creationDate.fromNow(); + } else { + creationDate = creationDate.format("MMMM Do, YYYY"); + } + + if (moment().diff(accessDate, 'months') < 6) { + accessDate = accessDate.fromNow(); + } else { + accessDate = accessDate.format("MMMM Do, YYYY"); + } + + var formattedDate = {creationDate: creationDate, accessDate: accessDate, timeoutDate: timeoutDate}; var json = {grant: this.model.toJSON(), client: this.options.client.toJSON(), formattedDate: formattedDate};