<s> from __future__ import unicode_literals <EOL> from datetime import date as real_date <EOL> from datetime import datetime as real_datetime <EOL> import re <EOL> import time <EOL> class date ( real_date ) : <EOL> def strftime ( self , fmt ) : <EOL> return strftime ( self , fmt ) <EOL> class datetime ( real_datetime ) : <EOL> def strftime ( self , fmt ) : <EOL> return strftime ( self , fmt ) <EOL> def combine ( self , date , time ) : <EOL> return datetime ( date . year , date . month , date . day , <EOL> time . hour , time . minute , time . microsecond , <EOL> time . tzinfo ) <EOL> def date ( self ) : <EOL> return date ( self . year , self . month , self . day ) <EOL> def new_date ( d ) : <EOL> """<STR_LIT>""" <EOL> return date ( d . year , d . month , d . day ) <EOL> def new_datetime ( d ) : <EOL> """<STR_LIT>""" <EOL> kw = [ d . year , d . month , d . day ] <EOL> if isinstance ( d , real_datetime ) : <EOL> kw . extend ( [ d . hour , d . minute , d . second , d . microsecond , d . tzinfo ] ) <EOL> return datetime ( * kw ) <EOL> _illegal_formatting = re . compile ( r"<STR_LIT>" ) <EOL> def _findall ( text , substr ) : <EOL> sites = [ ] <EOL> i = <NUM_LIT:0> <EOL> while <NUM_LIT:1> : <EOL> j = text . find ( substr , i ) <EOL> if j == - <NUM_LIT:1> : <EOL> break <EOL> sites . append ( j ) <EOL> i = j + <NUM_LIT:1> <EOL> return sites <EOL> def strftime ( dt , fmt ) : <EOL> if dt . year >= <NUM_LIT> : <EOL> return super ( type ( dt ) , dt ) . strftime ( fmt ) <EOL> illegal_formatting = _illegal_formatting . search ( fmt ) <EOL> if illegal_formatting : <EOL> msg = '<STR_LIT>' <EOL> raise TypeError ( msg . format ( illegal_formatting . group ( <NUM_LIT:0> ) ) ) <EOL> year = dt . year <EOL> delta = <NUM_LIT> - year <EOL> off = <NUM_LIT:6> * ( delta // <NUM_LIT:100> + delta // <NUM_LIT> ) <EOL> year += off <EOL> year += ( ( <NUM_LIT> - year ) // <NUM_LIT> ) * <NUM_LIT> <EOL> timetuple = dt . timetuple ( ) <EOL> s1 = time . strftime ( fmt , ( year , ) + timetuple [ <NUM_LIT:1> : ] ) <EOL> sites1 = _findall ( s1 , str ( year ) ) <EOL> s2 = time . strftime ( fmt , ( year + <NUM_LIT> , ) + timetuple [ <NUM_LIT:1> : ] ) <EOL> sites2 = _findall ( s2 , str ( year + <NUM_LIT> ) ) <EOL> sites = [ ] <EOL> for site in sites1 : <EOL> if site in sites2 : <EOL> sites . append ( site ) <EOL> s = s1 <EOL> syear = "<STR_LIT>" % ( dt . year , ) <EOL> for site in sites : <EOL> s = s [ : site ] + syear + s [ site + <NUM_LIT:4> : ] <EOL> return s </s>
