Forum: Ruby on Rails DateTime format YYYY-MM-DDTHH:MM:SSZ ????

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2f9a03aa0fcfe945229cb6126eda2cb2?d=identicon&s=25 Philip Hallstrom (Guest)
on 2006-04-25 22:44
(Received via mailing list)
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
E0c987f680cd640c14912ebfbf0f0f07?d=identicon&s=25 unknown (Guest)
on 2006-04-26 00:08
(Received via mailing list)
On 4/25/06, Philip Hallstrom <rails@philip.pjkh.com> 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
    http://books.xmlschemata.org/relaxng/ch19-77049.html
        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
2f9a03aa0fcfe945229cb6126eda2cb2?d=identicon&s=25 Philip Hallstrom (Guest)
on 2006-04-26 01:35
(Received via mailing list)
>
>
>       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.
This topic is locked and can not be replied to.