Skip to content
Advertisement

Tag: date

User-friendly time format in Python?

Python: I need to show file modification times in the “1 day ago”, “two hours ago”, format. Is there something ready to do that? It should be in English. Answer The code was originally published on a blog post “Python Pretty Date function” (http://evaisse.com/post/93417709/python-pretty-date-function) It is reproduced here as the blog account has been suspended and the page is no

Is there a function to determine which quarter of the year a date is in?

Sure I could write this myself, but before I go reinventing the wheel is there a function that already does this? Answer Given an instance x of datetime.date, (x.month-1)//3 will give you the quarter (0 for first quarter, 1 for second quarter, etc — add 1 if you need to count from 1 instead;-). Originally two answers, multiply upvoted and

Advertisement