in db,py
auth.settings.extra_fields['auth_user']= [Field('last_active', 
default=request.utcnow+datetime.timedelta(0,19800), readable=False, 
writable=False), Field('last_seen', 
default=request.utcnow+datetime.timedelta(0,19800), readable=False, 
writable=False)]

in controller

for person in people:
        s1=str(person.last_active)
        s2=str(person.last_seen)
        from datetime import datetime

        datetime1 = s2
        datetime1 = datetime.strptime(datetime1, "%Y-%m-%d %H:%M:%S.%f") # 
Converts string to datetime object
        datetime2 = request.utcnow+datetime.timedelta(0.19800)
        difference = (datetime1 - datetime2).seconds # Difference between 
the two datetimes in seconds
        
        temp="<p><b>%d. %s</b></p><p>Last activity at:%s</p><p>Last seen 
at:%s with diff: %s</p>"%(i,str(person.first_name) +" 
"+str(person.last_name), s1[:int((s1.index('.') ))], s2[:int((s2.index('.') 
))], str(datetime2) )
        i=i+1
        peoplelist.append(temp)
    return peoplelist


this one gives me an error. how to correct?

On Tuesday, April 19, 2016 at 12:18:21 PM UTC+5:30, [email protected] 
wrote:
>
> from datetime import datetime
>
>
> datetime1 = "2016-04-19 01:25:09.9090"
> datetime1 = datetime.strptime(datetime1, "%Y-%m-%d %H:%M:%S.%f") # Converts 
> string to datetime object
>
> datetime2 = "2016-04-19 01:25:09.8765"
> datetime2 = datetime.strptime(datetime2, "%Y-%m-%d %H:%M:%S.%f") # Converts 
> string to datetime object
>
> difference = (datetime1 - datetime2).seconds # Difference between the two 
> datetimes in seconds
>
> result = True if difference == 4 else False
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to