Skip to content

Commit

Permalink
fixed adding months and years to a date
Browse files Browse the repository at this point in the history
  • Loading branch information
ConceptJunkie committed Jan 31, 2024
1 parent ed86e22 commit 483a2e6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions rpn/time/rpnDateTimeClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 )
Expand Down

0 comments on commit 483a2e6

Please sign in to comment.