Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
typecast_date() argument format
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
jv  
View profile  
 More options Oct 7 2007, 11:30 am
From: jv <jesir.var...@gmail.com>
Date: Sun, 07 Oct 2007 15:30:58 -0000
Local: Sun, Oct 7 2007 11:30 am
Subject: typecast_date() argument format
Hello all.

I wonder if the function typecast_date() on /usr/lib/python2.5/site-
packages/django/db/backends/util.py:58 assumes the string 's' to be of
'YYYY-MM-DD' format.

Here's the function in question (as of r6460):

def typecast_date(s):
    return s and datetime.date(*map(int, s.split('-'))) or None

Should the above format be expected, would a sliced 's' be preferable,
like this:

def typecast_date(s):
    return s and datetime.date(*map(int, s[:N].split('-'))) or None

Where N could be, e.g., 10.

What do you think?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Malcolm Tredinnick  
View profile  
 More options Oct 7 2007, 11:40 am
From: Malcolm Tredinnick <malc...@pointy-stick.com>
Date: Sun, 07 Oct 2007 11:40:33 -0400
Local: Sun, Oct 7 2007 11:40 am
Subject: Re: typecast_date() argument format

Anything is possible, but what is your motivation for the change? Is
this another attempt to try and work around the fact that sometimes
fractional seconds are given? Or are you trying to pass in data that
hasn't been properly sanitised?

Without being able to assess the problem you are trying to solve, it's
hard to comment on the change.

Malcolm


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jv  
View profile  
 More options Oct 7 2007, 12:02 pm
From: jv <jesir.var...@gmail.com>
Date: Sun, 07 Oct 2007 16:02:53 -0000
Local: Sun, Oct 7 2007 12:02 pm
Subject: Re: typecast_date() argument format
I'm using sqlite3, where dates seem to be saved as bitstrings.  So,
when loading a date I get an error like

ValueError: invalid literal for int() with base 10:
'07T14:07:32.000006'

The actual date in the DB being

'2007-10-07T14:07:32.000006'

When using psycopg*, loading works.

On Oct 7, 11:40 am, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Malcolm Tredinnick  
View profile  
 More options Oct 7 2007, 12:24 pm
From: Malcolm Tredinnick <malc...@pointy-stick.com>
Date: Sun, 07 Oct 2007 12:24:37 -0400
Local: Sun, Oct 7 2007 12:24 pm
Subject: Re: typecast_date() argument format

On Sun, 2007-10-07 at 16:02 +0000, jv wrote:
> I'm using sqlite3, where dates seem to be saved as bitstrings.  So,
> when loading a date I get an error like

> ValueError: invalid literal for int() with base 10:
> '07T14:07:32.000006'

> The actual date in the DB being

> '2007-10-07T14:07:32.000006'

Right, so it is another one of these "fractional seconds" cases we've
been seeing lately. We certainly need to look at these, because there
are a number of them floating around at the moment (not sure why there's
the sudden influx lately, but that's completely unimportant).

I wouldn't be at all surprised if there's already a ticket open for this
issue, so you could have a search in Trac (in the database component)
and attach your patch there if there isn't already one available. If you
can't find an existing ticket, please do create a new one and attach
your patch. I'm not 100% sure that slicing is the right fix here (maybe
we can and should preserve the fractional part), but it's certainly a
bug at the moment.

Regards,
Malcolm


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jv  
View profile  
 More options Oct 7 2007, 12:30 pm
From: jv <jesir.var...@gmail.com>
Date: Sun, 07 Oct 2007 16:30:47 -0000
Local: Sun, Oct 7 2007 12:30 pm
Subject: Re: typecast_date() argument format
Thanks Malcom, I did search and found at least a similar (closed)
ticket (#659).  Yes, I agree the slicing is a workaround, and does not
look like a definite solution at all.

On Oct 7, 12:24 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »