Hi all -
Implementing my first web service with rails and trying things out using
the “/controller/invoke” interface. Mostly works fine.
But I have a function that takes a datetime and returns all rows that
are
newer than that. According to the log the SQL it’s generating is this:
SELECT * FROM xxxx WHERE (created_at >= ‘2006-04-25T13:18:31Z’)
I have never seen the “Z” appended like that before. I’m running mysql
4.1.18-standard and when I issue that command I get no results. If I
trim
the ‘Z’ I get what I expect. Also, with the Z I get a warning:
| Warning | 1292 | Truncated incorrect datetime value: ‘2006-04-25T13:23:31Z’ |
This is happening on rails 1.1.2.
Any ideas?
-philip
On 4/25/06, Philip H. [email protected] wrote:
Implementing my first web service with rails and trying things out using
the “/controller/invoke” interface. Mostly works fine.
But I have a function that takes a datetime and returns all rows that are
newer than that. According to the log the SQL it’s generating is this:
SELECT * FROM xxxx WHERE (created_at >= ‘2006-04-25T13:18:31Z’)
I have never seen the “Z” appended like that before.
The Z is part of the XSD::dateTime format to indicate the timezone
xsd:dateTime
This datatype describes instances identified by the
combination of a date
and a time. Its value space is described as a combination of
date and time
of day in Chapter 5.4 of ISO 8601. Its lexical space is the
extended format:
[-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]
The time zone may be specified as Z (UTC) or (+|-)hh:mm. Time
zones that
aren’t specified are considered undetermined.
The last time I was working with DateTime and a web service I used
DateTime.parse to convert the XSD format to something I could more
easily
work with; but:
http://www.recentrambles.com/pragmatic/view/33
The time zone may be specified as Z (UTC) or (+|-)hh:mm. Time zones that
aren't specified are considered undetermined.
The last time I was working with DateTime and a web service I used
DateTime.parse to convert the XSD format to something I could more easily
work with; but:
Well that makes sense. But I’ve got this for my api_method:
api_method :find_newer_than,
:expects => [{:created_at => :datetime}],
:returns => [[PokerRoom]]
So, why isn’t rails converting it into an actual datetime object before
it
gets that far and deal with the time zone?
I tried DateTime.parse, but get this:
private method `gsub!’ called for #<DateTime:
212012731397/86400,0,2299161>
which just plain baffles me.
http://www.recentrambles.com/pragmatic/view/33
Ugh.