Merge pull request #19523 from owncloud/fix-seconds-ago

Fix moment.js "a few seconds ago" with "seconds ago"
This commit is contained in:
Thomas Müller 2015-10-02 14:11:46 +02:00
commit 594a3e4e22
3 changed files with 6 additions and 2 deletions

View file

@ -58,7 +58,7 @@ describe('OCA.Files.MainFileInfoDetailView tests', function() {
expect(view.$el.find('.fileName h3').attr('title')).toEqual('One.txt');
expect(view.$el.find('.size').text()).toEqual('117.7 MB');
expect(view.$el.find('.size').attr('title')).toEqual('123456789 bytes');
expect(view.$el.find('.date').text()).toEqual('a few seconds ago');
expect(view.$el.find('.date').text()).toEqual('seconds ago');
expect(view.$el.find('.date').attr('title')).toEqual(dateExpected);
clock.restore();
});

View file

@ -76,7 +76,7 @@ describe('OCA.Versions.VersionsTabView', function() {
expect($versions.length).toEqual(2);
var $item = $versions.eq(0);
expect($item.find('.downloadVersion').attr('href')).toEqual(version1.getDownloadUrl());
expect($item.find('.versiondate').text()).toEqual('a few seconds ago');
expect($item.find('.versiondate').text()).toEqual('seconds ago');
expect($item.find('.revertVersion').length).toEqual(1);
expect($item.find('.preview').attr('src')).toEqual(version1.getPreviewUrl());

View file

@ -1533,6 +1533,10 @@ OC.Util = {
* @returns {string} human readable difference from now
*/
relativeModifiedDate: function (timestamp) {
var diff = moment().diff(moment(timestamp));
if (diff >= 0 && diff < 45000 ) {
return t('core', 'seconds ago');
}
return moment(timestamp).fromNow();
},
/**