#NEWLINE# def testDtParseRelative( self ) : #NEWLINE# #INDENT# ' Test dtparse with relative dates ' #NEWLINE# assertTrue = self . assertTrue #NEWLINE# assertRaises = self . assertRaises #NEWLINE# assertEqual = self . assertEqual #NEWLINE# ts = S3TimeSeries #NEWLINE# start = datetime . datetime ( 2014 , 1 , 3 , 11 , 30 ) #NEWLINE# result = ts . dtparse ( '+1 year' , start = start ) #NEWLINE# assertTrue ( isinstance ( result , datetime . datetime ) ) #NEWLINE# assertEqual ( result , datetime . datetime ( 2015 , 1 , 3 , 11 , 30 , 0 ) ) #NEWLINE# result = ts . dtparse ( '-3 days' , start = start ) #NEWLINE# assertTrue ( isinstance ( result , datetime . datetime ) ) #NEWLINE# assertEqual ( result , datetime . datetime ( 2013 , 12 , 31 , 11 , 30 , 0 ) ) #NEWLINE# result = ts . dtparse ( '+5 hours' , start = start ) #NEWLINE# assertTrue ( isinstance ( result , datetime . datetime ) ) #NEWLINE# assertEqual ( result , datetime . datetime ( 2014 , 1 , 3 , 16 , 30 , 0 ) ) #NEWLINE# result = ts . dtparse ( '-6 months' , start = start ) #NEWLINE# assertTrue ( isinstance ( result , datetime . datetime ) ) #NEWLINE# assertEqual ( result , datetime . datetime ( 2013 , 7 , 3 , 11 , 30 , 0 ) ) #NEWLINE# result = ts . dtparse ( '+12 weeks' , start = start ) #NEWLINE# assertTrue ( isinstance ( result , datetime . datetime ) ) #NEWLINE# assertEqual ( result , datetime . datetime ( 2014 , 3 , 28 , 11 , 30 , 0 ) ) #NEWLINE# result = ts . dtparse ( '' , start = start ) #NEWLINE# assertTrue ( isinstance ( result , datetime . datetime ) ) #NEWLINE# assertEqual ( result . year , start . year ) #NEWLINE# assertEqual ( result . month , start . month ) #NEWLINE# assertEqual ( result . day , start . day ) #NEWLINE# assertEqual ( result . hour , start . hour ) #NEWLINE# assertEqual ( result . minute , start . minute ) #NEWLINE# result = ts . dtparse ( None , start = start ) #NEWLINE# assertTrue ( isinstance ( result , datetime . datetime ) ) #NEWLINE# assertEqual ( result . year , start . year ) #NEWLINE# assertEqual ( result . month , start . month ) #NEWLINE# assertEqual ( result . day , start . day ) #NEWLINE# assertEqual ( result . hour , start . hour ) #NEWLINE# assertEqual ( result . minute , start . minute ) #NEWLINE# assertRaises ( ValueError , ts . dtparse , 'invalid' )