I am going to develop the time management sheet for that i have the one 
table name employee table and i am allready taken the login and logout time 
and i want to substract the time when i substract the time it show me in 
nanoseconds when i convert this nanosecond to the minute it totally 
confused me so if any one have solution please help me following is my 
controller and database :-
*
Table:-*

db.define_table('employee_detail',
                Field('employee_id'),
                Field('employee_name'),
                Field('employee_login_date','date'),
                Field('employee_logout_date','date'),
                Field('employee_login_time'),
                Field('employee_logout_time'),
                Field('total_time'))*

Controller:-*

def lgin(form):
    import datetime
    import time
    currentdate=datetime.date.today()
    now = time.localtime(time.time())
    session.sttime=time.time()
    currenttime = time.strftime("%H:%M:%S", now)
    session.time = currenttime
    #response.flash=currentdate
    for row in db(db.auth_user.email == 
auth.user.email).select(db.auth_user.first_name):
        firstname=row.first_name
    db.employee_detail.insert(employee_id = auth.user.email, 
employee_name=firstname, employee_login_date=currentdate, 
employee_login_time=currenttime)
    return '' 
     
def lgout(usr): 
    import datetime
    import time
    currentdate=datetime.date.today()
    now = time.localtime(time.time())
    ettime=time.time()
    duration = ettime-session.sttime
    du = str(duration / 60000000000)
    currenttime = time.strftime("%H:%M:%S", now) 
    db((db.employee_detail.employee_id == auth.user.email) & 
(db.employee_detail.employee_login_date == currentdate) & 
(db.employee_detail.employee_login_time == 
session.time)).update(employee_logout_date=currentdate, 
employee_logout_time=currenttime, total_time=du)  
    return '' 


Reply via email to