diff --git a/docs/datetime.rst b/docs/datetime.rst index ba846c4..f718881 100644 --- a/docs/datetime.rst +++ b/docs/datetime.rst @@ -13,5 +13,12 @@ Snippets about datetime. date_object = datetime.strptime('Jun 1 2005 1:33PM', '%b %d %Y %I:%M%p') + """ + 年份差计算 + """ + age = gmtime()[0] - self.birth_date.year + if gmtime()[1] >= self.birth_date.month: + age += 1 + return age .. _converting string into datetime: http://stackoverflow.com/questions/466345/converting-string-into-datetime