Skip to content

Commit

Permalink
Merge pull request #58 from VisionistInc/timestamps
Browse files Browse the repository at this point in the history
Added different timestamp format based on age of timestamp
  • Loading branch information
markgeraty committed Jul 30, 2015
2 parents e678eae + d12ebcf commit 972af55
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
15 changes: 14 additions & 1 deletion public/js/bundle/jibe.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ var Jibe = (function (BCSocket, CodeMirror, Replay, showdown, Timestamps, TextFo
client : client,
container : '#timestamps-container',
codemirror : editor,
format : 'YYYY-MM-DD HH:mm'
format : 'HH:mm'
});
}

Expand Down Expand Up @@ -1534,6 +1534,19 @@ function Timestamps (data) {
* Returns a timestamp string based on the format.
*/
this.getMoment = function (timestamp) {
var now = Date.now();

if(moment(now).year() !== moment(timestamp).year()){
this.format = "YYYY/MM/DD";
}
else if(moment(now).date() !== moment(timestamp).date()){
this.format = "MM/DD HH:mm";
}
else{
this.format = "HH:mm";
}


return moment (timestamp).format (this.format);
};

Expand Down
2 changes: 1 addition & 1 deletion public/js/jibe.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ var Jibe = (function (BCSocket, CodeMirror, Replay, showdown, Timestamps, TextFo
client : client,
container : '#timestamps-container',
codemirror : editor,
format : 'YYYY-MM-DD HH:mm'
format : 'HH:mm'
});
}

Expand Down
13 changes: 13 additions & 0 deletions public/js/timestamps.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ function Timestamps (data) {
* Returns a timestamp string based on the format.
*/
this.getMoment = function (timestamp) {
var now = Date.now();

if(moment(now).year() !== moment(timestamp).year()){
this.format = "YYYY/MM/DD";
}
else if(moment(now).date() !== moment(timestamp).date()){
this.format = "MM/DD HH:mm";
}
else{
this.format = "HH:mm";
}


return moment (timestamp).format (this.format);
};

Expand Down

0 comments on commit 972af55

Please sign in to comment.