#NEWLINE# def rfc3339_date( date ) : #NEWLINE# #INDENT# if date . tzinfo : #NEWLINE# #INDENT# time_str = date . strftime ( '%Y-%m-%dT%H:%M:%S' ) #NEWLINE# offset = date . tzinfo . utcoffset ( date ) #NEWLINE# timezone = ( ( ( offset . days * 24 ) * 60 ) + ( offset . seconds / 60 ) ) #NEWLINE# ( hour , minute ) = divmod ( offset , 60 ) #NEWLINE# return ( time_str + ( '%+03d:%02d' % ( hour , minute ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return date . strftime ( '%Y-%m-%dT%H:%M:%SZ' )