Commits

Anonymous committed d1ad71d

[svn] Date tag now passes all new tests.

Comments (0)

Files changed (2)

tests/test_date.py

         
         # test to < from
         self.assertEqual("about 4 hours", distance_of_time_in_words(datetime(2004, 3, 7, 1, 20), from_time))
-        self.assertEqual("less than 20 seconds", distance_of_time_in_words(datetime(2004, 3, 6, 21, 41, 38), from_time, True))
+        self.assertEqual("less than 20 seconds", distance_of_time_in_words(datetime(2004, 3, 6, 21, 41, 37), from_time, True))
 
         # test with integers
-        self.assertEqual("less than a minute", distance_of_time_in_words(50))
+        self.assertEqual("less than a minute", distance_of_time_in_words(29))
         self.assertEqual("about 1 hour", distance_of_time_in_words(60*60))
 
         # more cumbersome test with integers
-        self.assertEqual("less than a minute", distance_of_time_in_words(0, 50))
+        self.assertEqual("less than a minute", distance_of_time_in_words(0, 29))
         self.assertEqual("about 1 hour", distance_of_time_in_words(60*60, 0))
         
         # additional tests

webhelpers/rails/date.py

     
     Set ``include_seconds`` to True if you want more detailed approximations if distance < 1 minute
     """
-    #print from_time, to_time
     if isinstance(from_time, int):
         from_time = time.time()+from_time
     else:
         to_time = time.mktime(to_time.timetuple())
     
     distance_in_minutes = int(round(abs(to_time-from_time)/60))
-    distance_in_seconds = int(abs(to_time-from_time))
-    print distance_in_seconds, from_time, to_time
+    distance_in_seconds = int(round(abs(to_time-from_time)))
     
     if distance_in_minutes <= 1:
         if include_seconds:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.