Other helper methods¶
General utility functions used within Omnipresence.
- omnipresence.util.ago(then, now=None)[source]¶
Given a datetime object, return a string giving an approximate relative time, such as “5 days ago”.
- omnipresence.util.andify(seq, two_comma=False)[source]¶
Given a list, join its elements and return a string of the form “x and y” for a two-element list, or “x, y, and z” for three or more elements. If two_comma is True, insert a comma before “and” even if the list is only two elements long (“x, and y”).
- omnipresence.util.duration_to_timedelta(duration)[source]¶
Convert a duration of the form ”?w?d?h?m?s” into a datetime.timedelta object, where individual components are optional.