mirror of
https://github.com/kennethreitz/maya.git
synced 2026-06-05 06:46:14 +00:00
allow changing the locale for slang_time
This commit is contained in:
+9
-4
@@ -336,10 +336,15 @@ class MayaDT(object):
|
||||
dt = self.datetime(naive=True, to_timezone=self.local_timezone)
|
||||
return humanize.naturaldate(dt)
|
||||
|
||||
def slang_time(self):
|
||||
""""Returns human slang representation of time."""
|
||||
dt = self.datetime(naive=True, to_timezone=self.local_timezone)
|
||||
return humanize.naturaltime(dt)
|
||||
def slang_time(self, locale="en"):
|
||||
""""Returns human slang representation of time.
|
||||
|
||||
Keyword Arguments:
|
||||
locale -- locale to translate too, e.g. 'fr' for french.
|
||||
(default: 'en' - English)
|
||||
"""
|
||||
dt = self.datetime(to_timezone=self.local_timezone)
|
||||
return pendulum.instance(dt).diff_for_humans(locale=locale)
|
||||
|
||||
|
||||
def utc_offset(time_struct=None):
|
||||
|
||||
Reference in New Issue
Block a user