From 483a2e64851a53d9669c635cc548876785f54440 Mon Sep 17 00:00:00 2001 From: Rick Gutleber Date: Wed, 31 Jan 2024 11:13:43 -0500 Subject: [PATCH] fixed adding months and years to a date --- rpn/time/rpnDateTimeClass.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rpn/time/rpnDateTimeClass.py b/rpn/time/rpnDateTimeClass.py index 785cee2..859d2ac 100644 --- a/rpn/time/rpnDateTimeClass.py +++ b/rpn/time/rpnDateTimeClass.py @@ -25,6 +25,7 @@ import pendulum +from rpn.util.rpnDebug import debugPrint from rpn.units.rpnMeasurementClass import RPNMeasurement from rpn.special.rpnLocationLookup import lookUpLocation, lookUpTimeZone @@ -201,14 +202,14 @@ def add( self, time ): if not isinstance( time, RPNMeasurement ): ValueError( 'RPNMeasurement expected' ) - #print( 'time.getUnitName( )', time.getUnitName( ) ) - #print( 'g.unitOperators[ time.getUnitName( ) ].categories', g.unitOperators[ time.getUnitName( ) ].categories ) + debugPrint( 'time.getUnitName( )', time.getUnitName( ) ) + debugPrint( 'g.unitOperators[ time.getUnitName( ) ].categories', g.unitOperators[ time.getUnitName( ) ].categories ) - if 'years' in g.unitOperators[ time.getUnitName( ) ].categories: + if time.getUnitName( ) == 'year': years = time.value result = self.dateTime.add( years=int( years ) ) return RPNDateTime.convertFromPendulum( result, dateOnly=self.dateOnly ) - elif 'months' in g.unitOperators[ time.getUnitName( ) ].categories: + elif time.getUnitName( ) == 'month': months = time.value result = self.dateTime.add( months=int( months ) ) return RPNDateTime.convertFromPendulum( result, dateOnly=self.dateOnly )