diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2012-11-07 03:43:59 -0800 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2012-11-07 03:43:59 -0800 |
commit | d42d88d39193e712e727101a6f5656084061593b (patch) | |
tree | 2d79de475b8bfb70a47ebed0c9035150be4f31bd | |
parent | 3e01fe1dbb9e8f1830b7071f4368f23be04a4578 (diff) | |
parent | 50dbb30eb9968cd328915c4632f2742e6e41ad66 (diff) | |
download | nextcloud-server-d42d88d39193e712e727101a6f5656084061593b.tar.gz nextcloud-server-d42d88d39193e712e727101a6f5656084061593b.zip |
Merge pull request #289 from zimba12/master
Move function that relativizes dates from Files app to core
-rw-r--r-- | apps/files/js/files.js | 21 | ||||
-rw-r--r-- | core/js/js.js | 24 |
2 files changed, 24 insertions, 21 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 2d9ccba424a..7506000d216 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -829,27 +829,6 @@ function getSelectedFiles(property){ return files; } -function relative_modified_date(timestamp) { - var timediff = Math.round((new Date()).getTime() / 1000) - timestamp; - var diffminutes = Math.round(timediff/60); - var diffhours = Math.round(diffminutes/60); - var diffdays = Math.round(diffhours/24); - var diffmonths = Math.round(diffdays/31); - if(timediff < 60) { return t('files','seconds ago'); } - else if(timediff < 120) { return t('files','1 minute ago'); } - else if(timediff < 3600) { return t('files','{minutes} minutes ago',{minutes: diffminutes}); } - //else if($timediff < 7200) { return '1 hour ago'; } - //else if($timediff < 86400) { return $diffhours.' hours ago'; } - else if(timediff < 86400) { return t('files','today'); } - else if(timediff < 172800) { return t('files','yesterday'); } - else if(timediff < 2678400) { return t('files','{days} days ago',{days: diffdays}); } - else if(timediff < 5184000) { return t('files','last month'); } - //else if($timediff < 31556926) { return $diffmonths.' months ago'; } - else if(timediff < 31556926) { return t('files','months ago'); } - else if(timediff < 63113852) { return t('files','last year'); } - else { return t('files','years ago'); } -} - function getMimeIcon(mime, ready){ if(getMimeIcon.cache[mime]){ ready(getMimeIcon.cache[mime]); diff --git a/core/js/js.js b/core/js/js.js index 87d0a172082..2b2a64d25f9 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -675,6 +675,30 @@ function formatDate(date){ return $.datepicker.formatDate(datepickerFormatDate, date)+' '+date.getHours()+':'+((date.getMinutes()<10)?'0':'')+date.getMinutes(); } +/* takes an absolute timestamp and return a string with a human-friendly relative date + * @param int a Unix timestamp + */ +function relative_modified_date(timestamp) { + var timediff = Math.round((new Date()).getTime() / 1000) - timestamp; + var diffminutes = Math.round(timediff/60); + var diffhours = Math.round(diffminutes/60); + var diffdays = Math.round(diffhours/24); + var diffmonths = Math.round(diffdays/31); + if(timediff < 60) { return t('core','seconds ago'); } + else if(timediff < 120) { return t('core','1 minute ago'); } + else if(timediff < 3600) { return t('core','{minutes} minutes ago',{minutes: diffminutes}); } + //else if($timediff < 7200) { return '1 hour ago'; } + //else if($timediff < 86400) { return $diffhours.' hours ago'; } + else if(timediff < 86400) { return t('core','today'); } + else if(timediff < 172800) { return t('core','yesterday'); } + else if(timediff < 2678400) { return t('core','{days} days ago',{days: diffdays}); } + else if(timediff < 5184000) { return t('core','last month'); } + //else if($timediff < 31556926) { return $diffmonths.' months ago'; } + else if(timediff < 31556926) { return t('core','months ago'); } + else if(timediff < 63113852) { return t('core','last year'); } + else { return t('core','years ago'); } +} + /** * get a variable by name * @param string name |