<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> __license__ = '<STR_LIT>' <EOL> from datetime import datetime <EOL> import time <EOL> date_default_format = '<STR_LIT>' <EOL> def date_to_datetime ( from_date ) : <EOL> return datetime ( from_date . year , from_date . month , from_date . day ) <EOL> def date_to_string ( from_date , to_format ) : <EOL> return datetime ( from_date . year , from_date . month , from_date . day ) . strftime ( to_format ) <EOL> def date_to_timestamp ( from_date ) : <EOL> return time . mktime ( from_date . timetuple ( ) ) <EOL> def datetime_to_date ( from_datetime ) : <EOL> return from_datetime . date ( ) <EOL> def datetime_to_datetime ( from_datetime , to_format ) : <EOL> return datetime . strptime ( from_datetime . strftime ( to_format ) , to_format ) <EOL> def datetime_to_string ( from_datetime , to_format ) : <EOL> return from_datetime . strftime ( to_format ) <EOL> def datetime_to_timestamp ( from_datetime ) : <EOL> return time . mktime ( from_datetime . timetuple ( ) ) <EOL> def string_to_date ( string , current_format ) : <EOL> return datetime . strptime ( string , current_format ) . date ( ) <EOL> def string_to_datetime ( string , current_format , to_format = None ) : <EOL> if to_format : <EOL> return datetime . strptime ( datetime . strptime ( string , current_format ) . strftime ( to_format ) , to_format ) <EOL> return datetime . strptime ( string , current_format ) <EOL> def string_to_string ( string , current_format , to_format ) : <EOL> return datetime . strptime ( string , current_format ) . strftime ( to_format ) <EOL> def string_to_timestamp ( string , current_format ) : <EOL> return time . mktime ( datetime . strptime ( string , current_format ) . timetuple ( ) ) <EOL> def timestamp_to_date ( timestamp ) : <EOL> return datetime . fromtimestamp ( timestamp ) . date ( ) <EOL> def timestamp_to_datetime ( timestamp , to_format = None ) : <EOL> if to_format : <EOL> return datetime . strptime ( datetime . fromtimestamp ( timestamp ) . strftime ( to_format ) , to_format ) <EOL> return datetime . fromtimestamp ( timestamp ) <EOL> def timestamp_to_string ( timestamp , to_format ) : <EOL> return datetime . fromtimestamp ( timestamp ) . strftime ( to_format ) </s>
