<s> import datetime <EOL> COUCH_FORMATS = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> EXCEL_FORMAT = '<STR_LIT>' <EOL> def identity ( val , doc ) : <EOL> return val <EOL> def couch_to_excel_datetime ( val , doc ) : <EOL> if isinstance ( val , basestring ) : <EOL> dt_val = None <EOL> for fmt in COUCH_FORMATS : <EOL> try : <EOL> dt_val = datetime . datetime . strptime ( val , fmt ) <EOL> except ValueError : <EOL> pass <EOL> else : <EOL> break <EOL> if dt_val is not None : <EOL> try : <EOL> return dt_val . strftime ( EXCEL_FORMAT ) <EOL> except ValueError : <EOL> pass <EOL> return val </s>
