def index(): user = BankAccount(session['username'], 0) rec_trans = [] for x in user.recents(): a, b, c = x fromz = tz.tzutc() toz = tz.tzlocal() utc = datetime.strptime(b, '%Y-%m-%d %H:%M:%S.%f') utc = utc.replace(tzinfo=fromz) b = utc.astimezone(toz) rec_trans.append([ str(b.date()) + ' ' + str(b.hour) + ':' + str(b.minute) + ':' + str(b.second), str(c) ]) rec_trans = list(reversed(rec_trans))[0:9] return render_template('index.html', amount=str(user.getBalance()), username=session['username'], recents=convert(rec_trans))