Skip to content

Commit

Permalink
dates: change disctance_of_time_in_words in docs to mirror pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
ergo committed Sep 14, 2015
1 parent 63ccc2e commit fc308b1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/blog_models_and_views.rst
Expand Up @@ -88,7 +88,7 @@ Your project structure should look like this at this point::
Now it is time to add imports and properties to **models/blog_record.py**::

from webhelpers2.text import urlify #<- will generate slugs
from webhelpers2.date import time_ago_in_words #<- human friendly dates
from webhelpers2.date import distance_of_time_in_words #<- human friendly dates


And to model itself::
Expand All @@ -104,7 +104,7 @@ be approximated to their closest counterparts.

@property
def created_in_words(self):
return time_ago_in_words(self.created)
return distance_of_time_in_words(self.created, datetime.datetime.utcnow())

This property will return information when specific entry was created in a
friendly form like "2 days ago".
Expand Down
4 changes: 2 additions & 2 deletions docs/blog_models_and_views_src.rst
Expand Up @@ -45,7 +45,7 @@ Contents of models/blog_record.py::
DateTime #<- time abstraction field,
)
from webhelpers2.text import urlify #<- will generate slugs
from webhelpers2.date import time_ago_in_words #<- human friendly dates
from webhelpers2.date import distance_of_time_in_words #<- human friendly dates

class BlogRecord(Base):
__tablename__ = 'entries'
Expand All @@ -61,7 +61,7 @@ Contents of models/blog_record.py::

@property
def created_in_words(self):
return time_ago_in_words(self.created)
return distance_of_time_in_words(self.created, datetime.datetime.utcnow())



Expand Down
2 changes: 0 additions & 2 deletions pyramid_blogr/models/blog_record.py
Expand Up @@ -24,6 +24,4 @@ def slug(self):

@property
def created_in_words(self):
# Can't use time_ago_in_words(self.created) since self.created
# is UTC, but that function compares against local time
return distance_of_time_in_words(self.created, datetime.datetime.utcnow())

0 comments on commit fc308b1

Please sign in to comment.