#NEWLINE# def _normalize_interval( start , end , value ) : #NEWLINE# #INDENT# '\n    Normalize datetime intervals.\n\n    Given a pair of datetime.date or datetime.datetime objects,\n    returns a 2-tuple of tz-aware UTC datetimes spanning the same interval.\n\n    For datetime.date objects, the returned interval starts at 00:00:00.0\n    on the first date and ends at 00:00:00.0 on the second.\n\n    Naive datetimes are upgraded to UTC.\n\n    Timezone-aware datetimes are normalized to the UTC tzdata.\n\n    Params:\n        - start: A date or datetime\n        - end: A date or datetime\n    ' #NEWLINE# if ( not isinstance ( start , datetime ) ) : #NEWLINE# #INDENT# start = datetime . combine ( start , START_OF_DAY ) #NEWLINE# end = datetime . combine ( end , START_OF_DAY ) #NEWLINE# #UNINDENT# if ( start . tzinfo is None ) : #NEWLINE# #INDENT# start = pytz . UTC . localize ( start ) #NEWLINE# end = pytz . UTC . localize ( end ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# start = start . astimezone ( pytz . UTC ) #NEWLINE# end = end . astimezone ( pytz . UTC ) #NEWLINE# #UNINDENT# return ( start , end )