Repository: ckan/ckan

Issue:
CKAN 2.9 Time at acitivity stream
### CKAN Version
2.9


### Expected behavior
Time is showed in the right format (like in CKAN 2.8)

### Actual behaviour
Time displayed like a float number 
![Screenshot_2020-02-12](https://user-images.githubusercontent.com/13872453/74324214-5b8f4700-4d8f-11ea-9fa7-cc66cfeb3a27.png)


### Steps to reproduce
1. Set up pure CKAN
2. Create Org nad dataset to it.
3. Open Activity steam tab.



Discussion:

Resolving patch:
diff --git a/ckan/lib/formatters.py b/ckan/lib/formatters.py
--- a/ckan/lib/formatters.py
+++ b/ckan/lib/formatters.py
@@ -120,10 +120,10 @@ def months_between(date1, date2):
                     return _('Just now')
                 else:
                     return ungettext('{mins} minute ago', '{mins} minutes ago',
-                                     seconds / 60).format(mins=seconds / 60)
+                                     seconds // 60).format(mins=seconds // 60)
             else:
                 return ungettext('{hours} hour ago', '{hours} hours ago',
-                                 seconds / 3600).format(hours=seconds / 3600)
+                                 seconds // 3600).format(hours=seconds // 3600)
         # more than one day
         months = months_between(datetime_, now)
 
@@ -134,7 +134,7 @@ def months_between(date1, date2):
             return ungettext('{months} month ago', '{months} months ago',
                              months).format(months=months)
         return ungettext('over {years} year ago', 'over {years} years ago',
-                         months / 12).format(years=months / 12)
+                         months // 12).format(years=months // 12)
 
     # actual date
     details = {


Test patch:
diff --git a/ckan/tests/lib/test_helpers.py b/ckan/tests/lib/test_helpers.py
--- a/ckan/tests/lib/test_helpers.py
+++ b/ckan/tests/lib/test_helpers.py
@@ -505,6 +505,60 @@ def test_render_datetime(date, extra, exp):
     assert h.render_datetime(date, **extra) == exp
 
 
+@pytest.mark.freeze_time("2020-02-17 12:00:00")
+@pytest.mark.parametrize(
+    "date, exp",
+    [
+        (
+            datetime.datetime(2020, 2, 17, 11, 59, 30),
+            "Just now",
+        ),
+        (
+            datetime.datetime(2020, 2, 17, 11, 59, 0),
+            "1 minute ago",
+        ),
+        (
+            datetime.datetime(2020, 2, 17, 11, 55, 0),
+            "5 minutes ago",
+        ),
+        (
+            datetime.datetime(2020, 2, 17, 11, 0, 0),
+            "1 hour ago",
+        ),
+        (
+            datetime.datetime(2020, 2, 17, 7, 0, 0),
+            "5 hours ago",
+        ),
+        (
+            datetime.datetime(2020, 2, 16, 12, 0, 0),
+            "1 day ago",
+        ),
+        (
+            datetime.datetime(2020, 2, 12, 12, 0, 0),
+            "5 days ago",
+        ),
+        (
+            datetime.datetime(2020, 1, 17, 12, 0, 0),
+            "1 month ago",
+        ),
+        (
+            datetime.datetime(2019, 9, 17, 12, 0, 0),
+            "5 months ago",
+        ),
+        (
+            datetime.datetime(2019, 1, 17, 12, 0, 0),
+            "over 1 year ago",
+        ),
+        (
+            datetime.datetime(2015, 1, 17, 12, 0, 0),
+            "over 5 years ago",
+        ),
+    ]
+)
+def test_time_ago_from_timestamp(date, exp):
+    assert h.time_ago_from_timestamp(date) == exp
+
+
 def test_clean_html_disallowed_tag():
     assert h.clean_html("<b><bad-tag>Hello") == u"<b>&lt;bad-tag&gt;Hello</b>"