On Mon, 2011-11-21 at 04:48 -0800, Rahul wrote:
> my model (db.py)-------------
>
> db.define_table('updates',
> Field('description', 'text'),
> Field('updated_on','date', readable=False,
> writable=False, default=now),
> Field('posted_by', readable=False, writable=False,
> length=512)
> )
What's inside "now"?
It must be a datetime.datetime() or a "%Y-%m-%d %H:%M:%S" date, not a
unix timestamp. Usually request.now fits, if you need to store current
date/time.
If you want to convert a timestamp into datetime object::
datetime.datetime.fromtimestamp(1321882700)
If you want to convert a date in a given format into a datetime:
datetime.datetime.strptime(string, format)
(Where format is the same accepted by ``strftime()``).
By the way: why does sqlite tries to parse the date with fixed format
instead of using ``datetime.datetime.strptime()``? Somebody can explain
that?
--
Samuele ~redShadow~ Santi
----------------------------------------------------------------
redshadow[at]hackzine.org - redshadowhack[at]gmail.com
Blog: http://hackzine.org
GPG Key signature:
050D 3E9F 6E0B 44CE C008 D1FC 166C 3C7E EB26 4933
----------------------------------------------------------------
/me recommends:
Squadra Informatica - http://www.squadrainformatica.com
----------------------------------------------------------------
- Proud ThinkPad T-Series owner
- Registered Linux-User: #440008
* GENTOO User since 1199142000 (2008-01-01)
* former DEBIAN SID user
----------------------------------------------------------------
"Software is like sex: it's better when it's free!"
-- Linus Torvalds
signature.asc
Description: This is a digitally signed message part

