From 4b3a5a257f0861db23b8d97836afdf398b3fef9a Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 2 Oct 2015 10:16:21 +0200 Subject: Fix moment.js "a few seconds ago" with "seconds ago" * fixes #18627 --- apps/files/tests/js/mainfileinfodetailviewSpec.js | 2 +- apps/files_versions/tests/js/versionstabviewSpec.js | 2 +- core/js/js.js | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/files/tests/js/mainfileinfodetailviewSpec.js b/apps/files/tests/js/mainfileinfodetailviewSpec.js index 2b9e2b23f93..f4403196f2e 100644 --- a/apps/files/tests/js/mainfileinfodetailviewSpec.js +++ b/apps/files/tests/js/mainfileinfodetailviewSpec.js @@ -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(); }); diff --git a/apps/files_versions/tests/js/versionstabviewSpec.js b/apps/files_versions/tests/js/versionstabviewSpec.js index 4435f38ef7e..306dd66be2a 100644 --- a/apps/files_versions/tests/js/versionstabviewSpec.js +++ b/apps/files_versions/tests/js/versionstabviewSpec.js @@ -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()); diff --git a/core/js/js.js b/core/js/js.js index e40141ac617..36fa90e78a3 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -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(); }, /** -- cgit v1.2.3