From 2428d520dab661dc998e92987042d62044ceecd4 Mon Sep 17 00:00:00 2001 From: Yusei Tahara <yusei@nexedi.com> Date: Tue, 23 Mar 2010 10:15:44 +0000 Subject: [PATCH] Add copyDate function. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33993 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/DateUtils.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/product/ERP5Type/DateUtils.py b/product/ERP5Type/DateUtils.py index 3d07262d26..c15c6214ac 100644 --- a/product/ERP5Type/DateUtils.py +++ b/product/ERP5Type/DateUtils.py @@ -42,7 +42,8 @@ security.declarePublic('addToDate', 'getClosestDate', 'getMonthFraction', 'getYearFraction', 'getAccountableYearFraction', 'getBissextilCompliantYearFraction', 'getIntervalListBetweenDates', 'getDecimalNumberOfYearsBetween','roundMonthToGreaterEntireYear', - 'roundDate', 'convertDateToHour', 'getNumberOfDayInMonth', 'atTheEndOfPeriod') + 'roundDate', 'convertDateToHour', 'getNumberOfDayInMonth', 'atTheEndOfPeriod', + 'copyDate') millis = DateTime('2000/01/01 12:00:00.001') - DateTime('2000/01/01 12:00:00') centis = millis * 10 @@ -519,3 +520,23 @@ def atTheEndOfPeriod(date, period): else: raise NotImplementedError, 'Period "%s" not Handled yet' % period return end + +def copyDate(date, year=None, month=None, day=None, + hour=None, minute=None, second=None, timezone=None): + if year is None: + year = datetime.year() + if month is None: + month = datetime.month() + if day is None: + day = datetime.day() + if hour is None: + hour = datetime.hour() + if minute is None: + minute = datetime.minute() + if second is None: + second = datetime.second() + if timezone is None: + timezone = datetime.timezone() + return DateTime('%i/%i/%i %i:%i:%d %s' % (year, month, day, + hour, minute, second, + timezone)) -- 2.30.9