From 557cc93aae95e85cd2d9cb662127b3aec0c86a3b Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Mon, 2 Feb 2009 15:07:15 +0100 Subject: [PATCH] [IMP] Add a new function, last_day_of_current_month, this function returns the last day of the current month. bzr revid: stephane@tinyerp.com-20090202140715-e5lw28lvrd9fep13 --- bin/osv/orm.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 737fc40c194..ff48da700a0 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -40,6 +40,7 @@ # import time +import calendar import types import string import netsvc @@ -62,6 +63,12 @@ from tools.config import config regex_order = re.compile('^([a-zA-Z0-9_]+( desc)?( asc)?,?)+$', re.I) +def last_day_of_current_month(): + import datetime + import calendar + today = datetime.date.today() + last_day = str(calendar.monthrange(today.year, today.month)[1]) + return time.strftime('%Y-%m-' + last_day) def intersect(la, lb): return filter(lambda x: x in lb, la)