aboutsummaryrefslogtreecommitdiff
path: root/mod/identica/views/default/js
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2013-11-09 16:16:08 +0100
committerSem <sembrestels@riseup.net>2013-11-09 16:16:08 +0100
commite58937426578eac71d1447c38ae3f93cbc331bf1 (patch)
tree3bac3ed5c025f05250d7c07b14f8b83135e07233 /mod/identica/views/default/js
parent293fe873dcbedf45571807b722ce859e00a5a3a5 (diff)
parentd2494d74da2f015465bb340292c049d9c63756cd (diff)
downloadelgg-e58937426578eac71d1447c38ae3f93cbc331bf1.tar.gz
elgg-e58937426578eac71d1447c38ae3f93cbc331bf1.tar.bz2
Add 'mod/identica/' from commit 'd2494d74da2f015465bb340292c049d9c63756cd'
git-subtree-dir: mod/identica git-subtree-mainline: 293fe873dcbedf45571807b722ce859e00a5a3a5 git-subtree-split: d2494d74da2f015465bb340292c049d9c63756cd
Diffstat (limited to 'mod/identica/views/default/js')
-rw-r--r--mod/identica/views/default/js/friendly_time.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/mod/identica/views/default/js/friendly_time.php b/mod/identica/views/default/js/friendly_time.php
new file mode 100644
index 000000000..0b0275206
--- /dev/null
+++ b/mod/identica/views/default/js/friendly_time.php
@@ -0,0 +1,50 @@
+elgg.get_friendly_time = function(time) {
+
+ if (!time) {
+ time = new Date();
+ } else {
+ time = new Date(time);
+ }
+ diff = (new Date().getTime() - time.getTime()) / 1000;
+
+ minute = 60;
+ hour = minute * 60;
+ day = hour * 24;
+
+ if (diff < minute) {
+ return elgg.echo("friendlytime:justnow");
+ } else if (diff < hour) {
+ diff = Math.round(diff / minute);
+ if (diff == 0) {
+ diff = 1;
+ }
+
+ if (diff > 1) {
+ return elgg.echo("friendlytime:minutes", [diff]);
+ } else {
+ return elgg.echo("friendlytime:minutes:singular", [diff]);
+ }
+ } else if (diff < day) {
+ diff = Math.round(diff / hour);
+ if (diff == 0) {
+ diff = 1;
+ }
+
+ if (diff > 1) {
+ return elgg.echo("friendlytime:hours", [diff]);
+ } else {
+ return elgg.echo("friendlytime:hours:singular", [diff]);
+ }
+ } else {
+ diff = Math.round(diff / day);
+ if (diff == 0) {
+ diff = 1;
+ }
+
+ if (diff > 1) {
+ return elgg.echo("friendlytime:days", [diff]);
+ } else {
+ return elgg.echo("friendlytime:days:singular", [diff]);
+ }
+ }
+};