qwikMetadataDate
- RSSの時刻にGMTとついてくるが,この時刻はJSTのまま
調査
時刻を出しているところは rfc1123_date を呼んでいる.
# Config data.
@last_build_date = Time.now.rfc1123_date
# @last_build_date = @req.start_time.rfc1123_date # No @req here.
@last_build_date = Time.at(0).rfc1123_date if @config.test
これは lib/qwik/util-time.rb で定義されている
def rfc1123_date
return strftime('%a, %d %b %Y %H:%M:%S GMT') # Sat, 01 Jan 2000 12:34:56 GMT
end
ここで GMT と決めうちしているのが問題なので,rfc2822_date メソッドを作って util-time.rbでタイムゾーンもちゃんと自サイトのところを取ってくるようにする.
def rfc2822_date
return strftime('%a, %d %b %Y %H:%M:%S %z') # Sat, 01 Jan 2000 12:34:56 +0900
end
で,rfc1123_date ではなく rfc2822_date を呼ぶようにすれば良いのではないか.
仕様
Atom1.0
仕様 http://tools.ietf.org/html/rfc4287.html#page-10
A Date construct is an element whose content MUST conform to the "date-time" production in [RFC3339]. In addition, an uppercase "T" character MUST be used to separate date and time, and an uppercase "Z" character MUST be present in the absence of a numeric time zone offset.
atomDateConstruct =
atomCommonAttributes,
xsd:dateTime
Such date values happen to be compatible with the following specifications: [ISO.8601.1988], [W3C.NOTE-datetime-19980827], and [W3C.REC-xmlschema-2-20041028].
Example Date constructs:
<updated>2003-12-13T18:30:02Z</updated> <updated>2003-12-13T18:30:02.25Z</updated> <updated>2003-12-13T18:30:02+01:00</updated> <updated>2003-12-13T18:30:02.25+01:00</updated>
Date values SHOULD be as accurate as possible. For example, it would be generally inappropriate for a publishing system to apply the same timestamp to several entries that were published during the course of a single day.
RSS 2.0
GMTのかわりにJSTという感じではなくて,
Sat, 01 Jan 2000 12:34:56 +0900
という形が望ましい. RSS2.0の仕様 http://blogs.law.harvard.edu/tech/rss には
All date-times in RSS conform to the Date and Time Specification of RFC 822
と書いてあるが,RFC822はすでに obsolete で,現行は RFC2822 http://www.puni.net/~mimori/rfc/rfc2822.txt なので, これにある
zone = (( "+" / "-" ) 4DIGIT) / obs-zone
にしたがうことにする.と考えたが,そもそも RFC822 が obsolete かどうかは RSS 2.0 の仕様的には問題ではなく,参照しているのはあくまでも RFC822 なので, あくまでも RFC822 スタイルの date を出した方がよいのではないか.
Ruby的には,「%z」でこのタイムゾーンが取り出せる.しかし http://d.hatena.ne.jp/walf443/20060601/1149155096 によれば「%z」はOSの実装に 依存するらしい (http://www.ruby-lang.org/ja/man/?cmd=view;name=trap%3A%3ATime ). 本来的には Time.now.rfc2822 や Time.now.xmlschema を使うのがよいようだ.
実装
Sep-21-2006 時点.
- util-time.rb
*** util-time.rb.bak Thu Jul 20 16:55:40 2006
--- util-time.rb Thu Sep 21 18:11:19 2006
***************
*** 34,39 ****
--- 34,43 ----
return strftime('%a, %d %b %Y %H:%M:%S GMT') # Sat, 01 Jan 2000 12:34:56 GMT
end
+ def rfc2822_date
+ return strftime('%a, %d %b %Y %H:%M:%S %z') # Sat, 01 Jan 2000 12:34:56 +0900
+ end
+
def rfc_date
return strftime('%Y-%m-%dT%H:%M:%S') # 2000-01-01T12:34:56
end
***************
*** 85,90 ****
--- 89,95 ----
assert_equal "2000-01-01(Sat) 12:34:56", t.ymdax
assert_equal "2000-01-01 (土) 12:34:56", t.format_date
assert_equal 'Sat, 01 Jan 2000 12:34:56 GMT', t.rfc1123_date
+ assert_equal 'Sat, 01 Jan 2000 12:34:56 +0900', t.rfc2822_date
assert_equal '2000-01-01T12:34:56', t.rfc_date
end
end
- act-metadata.rb
% diff -c act-metadata.rb{.bak,}
*** act-metadata.rb.bak Thu Jul 20 16:55:39 2006
--- act-metadata.rb Thu Sep 21 17:49:17 2006
***************
*** 234,240 ****
@description = 'a private qwikWeb site.
Since this site is in private mode, the feed includes minimum data.'
@language = 'ja' # should be configurable?
! @pub_date = @site.last_page_time.rfc1123_date
}
if @public
--- 234,240 ----
@description = 'a private qwikWeb site.
Since this site is in private mode, the feed includes minimum data.'
@language = 'ja' # should be configurable?
! @pub_date = @site.last_page_time.rfc2822_date
}
if @public
***************
*** 245,253 ****
@image_url = 'http://qwik.jp/.theme/i/favicon.png'
# Config data.
! @last_build_date = Time.now.rfc1123_date
# @last_build_date = @req.start_time.rfc1123_date # No @req here.
! @last_build_date = Time.at(0).rfc1123_date if @config.test
@updated = Time.now.rfc_date
@updated = Time.at(0).rfc_date if @config.test
--- 245,253 ----
@image_url = 'http://qwik.jp/.theme/i/favicon.png'
# Config data.
! @last_build_date = Time.now.rfc2822_date
# @last_build_date = @req.start_time.rfc1123_date # No @req here.
! @last_build_date = Time.at(0).rfc2822_date if @config.test
@updated = Time.now.rfc_date
@updated = Time.at(0).rfc_date if @config.test
***************
*** 265,272 ****
title = page.key
url = @site.page_url(page.key)
! description = page.mtime.rfc1123_date
! pub_date = page.mtime.rfc1123_date
updated = page.mtime.rfc_date+'Z'
if @public
--- 265,272 ----
title = page.key
url = @site.page_url(page.key)
! description = page.mtime.rfc2822_date
! pub_date = page.mtime.rfc2822_date
updated = page.mtime.rfc_date+'Z'
if @public
***************
*** 299,306 ****
@site.date_list.each {|page|
title = page.key
url = @site.page_url(page.key)
! description = page.mtime.rfc1123_date
! pub_date = page.mtime.rfc1123_date
updated = page.mtime.rfc_date+'Z'
if @public
--- 299,306 ----
@site.date_list.each {|page|
title = page.key
url = @site.page_url(page.key)
! description = page.mtime.rfc2822_date
! pub_date = page.mtime.rfc2822_date
updated = page.mtime.rfc_date+'Z'
if @public
チェック
古い方
><pubdate >Thu, 17 Aug 2006 17:52:34 GMT</pubdate ><lastbuilddate >Thu, 17 Aug 2006 17:57:48 GMT</lastbuilddate >
のようになっている.
変更後
><pubdate >Tue, 05 Sep 2006 18:50:20 +0900</pubdate ><lastbuilddate >Thu, 21 Sep 2006 18:22:01 +0900</lastbuilddate >
影響範囲
rfc1123_date は act-metadata.rb のほかにも,act-mdlb.rb と modulobe.rb からも呼んでいます.
