On 28/03/2011 1:38pm, django beginner wrote:
hi django experts,

how do I strip the following string in python (Charfield format)

14:00
3:00
Do you also keep am and pm? What about UTC offsets?

You need a helper method to interpret the numbers, convert them to seconds, do the comparison and return True or False to your view or model depending on when you need to know.

If the data is entered by humans you might have a different problem. Somehow you need to make sure the users enter what they actually meant rather than what you see in the charfield.

It would be good to insist on 03:00 rather than 3:00 for a start. Look at properly formatting the data before saving it.

I would try to do a bit of error detection and perhaps any easy corrections (like 3 to 03) in client-side javascript or a widget before the server sees it. Depends where your performance bottlenecks will be.

Mike
wherein I could compare the results - convert in integer:

if 14>  3 . . .

thanks in advance!


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to