<s> """<STR_LIT>""" <EOL> import calendar <EOL> import datetime <EOL> import time <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> try : <EOL> long , unicode , basestring <EOL> except NameError : <EOL> long , unicode , basestring = int , str , str <EOL> numeric = ( int , long , float ) <EOL> sequence = ( list , tuple ) <EOL> date = ( datetime . datetime , datetime . date ) <EOL> def timetopythonvalue ( time_val ) : <EOL> "<STR_LIT>" <EOL> if isinstance ( time_val , sequence ) : <EOL> return map ( timetopythonvalue , time_val ) <EOL> elif isinstance ( time_val , numeric ) : <EOL> return datetime . datetime ( * ( time . gmtime ( time_val ) ) [ : <NUM_LIT:6> ] ) <EOL> elif isinstance ( time_val , numeric ) : <EOL> values = [ ] <EOL> try : <EOL> values = map ( long , time_val . split ( "<STR_LIT:U+002C>" ) ) <EOL> except : <EOL> pass <EOL> if values : <EOL> return map ( timetopythonvalue , values ) <EOL> raise ValueError ( repr ( time_val ) ) <EOL> def pythonvaluetotime ( time_val ) : <EOL> "<STR_LIT>" <EOL> if time_val is None : <EOL> return None <EOL> elif isinstance ( time_val , numeric ) : <EOL> return str ( long ( time_val * <NUM_LIT> ) ) <EOL> elif isinstance ( time_val , date ) : <EOL> dtlist = [ time_val . year , time_val . month , time_val . day ] <EOL> if isinstance ( time_val , datetime . datetime ) : <EOL> dtlist += [ time_val . hour , time_val . minute , time_val . second ] <EOL> else : <EOL> dtlist += [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> return long ( calendar . timegm ( dtlist ) * <NUM_LIT> ) <EOL> elif ( isinstance ( time_val , sequence ) <EOL> and len ( time_val ) == <NUM_LIT:2> ) : <EOL> if all ( isinstance ( x , numeric ) <EOL> for x in time_val ) : <EOL> return "<STR_LIT:U+002C>" . join ( pythonvaluetotime ( x ) <EOL> for x in time_val ) <EOL> elif all ( isinstance ( x , date ) <EOL> for x in time_val ) : <EOL> return "<STR_LIT:U+002C>" . join ( pythonvaluetotime ( x ) <EOL> for x in time_val ) <EOL> raise ValueError ( repr ( time_val ) ) </s>
