#NEWLINE# def timesince( value ) : #NEWLINE# #INDENT# now = datetime . datetime . utcnow ( ) #NEWLINE# delta = ( now - value ) #NEWLINE# if ( delta . days > 365 ) : #NEWLINE# #INDENT# return _ ( '%(num)i years ago' , num = ( delta . days / 365 ) ) #NEWLINE# #UNINDENT# if ( delta . days > 30 ) : #NEWLINE# #INDENT# return _ ( '%(num)i months ago' , num = ( delta . days / 30 ) ) #NEWLINE# #UNINDENT# if ( delta . days > 0 ) : #NEWLINE# #INDENT# return _ ( '%(num)i days ago' , num = delta . days ) #NEWLINE# #UNINDENT# if ( delta . seconds > 3600 ) : #NEWLINE# #INDENT# return _ ( '%(num)i hours ago' , num = ( delta . seconds / 3600 ) ) #NEWLINE# #UNINDENT# if ( delta . seconds > 60 ) : #NEWLINE# #INDENT# return _ ( '%(num)i minutes ago' , num = ( delta . seconds / 60 ) ) #NEWLINE# #UNINDENT# return _ ( 'just now' )