date format

U

Une Bévue

I'm building a sitemap.xml using ruby, one input "lastmod" is expected
as :

<lastmod>2011-03-23T08:08:39+00:00</lastmod>

using :

File.mtime(path) i get :

<lastmod>2011-03-29 13:16:12 +0200</lastmod>

are those different ?

if yes, how to switch to the first one ?
 
Y

Y. NOBUOKA

Hi,
I'm building a sitemap.xml using ruby, one input "lastmod" is expected
as :

=A0<lastmod>2011-03-23T08:08:39+00:00</lastmod>

using :

File.mtime(path) i get :

=A0<lastmod>2011-03-29 13:16:12 +0200</lastmod>

are those different ?

Yes. There are several formats to represent time.
And when you use in a sitemap.xml, you should represent
time in the former format [1].

[1] http://www.sitemaps.org/protocol.php
if yes, how to switch to the first one ?

You can do it by using a Time#xmlschema method [2].
To use this method, you must do require 'time' module.
See example below:

[2] http://www.ruby-doc.org/core-1.9/classes/Time.html#M000333

$ irb
ruby-1.9.2-p136 :001 > require 'time'
=3D> true
ruby-1.9.2-p136 :002 > File.mtime( 'test' ).xmlschema
=3D> "2011-03-30T13:34:40+09:00"

Regards,
--=20
NOBUOKA Yu
 
U

Une Bévue

Y. NOBUOKA said:
Yes. There are several formats to represent time.
And when you use in a sitemap.xml, you should represent
time in the former format [1].

[1] http://www.sitemaps.org/protocol.php
if yes, how to switch to the first one ?

You can do it by using a Time#xmlschema method [2].
To use this method, you must do require 'time' module.
See example below:

[2] http://www.ruby-doc.org/core-1.9/classes/Time.html#M000333

$ irb
ruby-1.9.2-p136 :001 > require 'time'
=> true
ruby-1.9.2-p136 :002 > File.mtime( 'test' ).xmlschema
=> "2011-03-30T13:34:40+09:00"

ok, fine, cristal clear, thanks a lot !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,129
Messages
2,570,771
Members
47,329
Latest member
FidelRauch

Latest Threads

Top