RSSフィード用のXMLを組み立てようとして、dateコマンドのオプションを調べていた。--rfc-822というオプションがあるらしいのだが、Mac OS X 10.4.10のターミナル上で実行してみたが、有効ではない。
仕方がないので、わざわざAppleScriptでフルスクラッチで書いた。夜遅くに家でダラダラ書いていたので、無駄に長いし美しくない(ーー;;;
ret_rfc822date() of me
on ret_rfc822date()
set curDay to current date
set dayText to text 1 thru 3 of (weekday of (curDay) as text)
set dateText to "00" & day of curDay
set dateText to text ((length of dateText) - 1) thru -1 of dateText
set monText to text 1 thru 3 of (month of (curDay) as text)
set yearText to year of (curDay)
set hText to "0" & ((time of (curDay)) div 3600) as text
set hText to text ((length of hText) - 1) thru -1 of hText
set mText to "0" & ((time of (curDay)) mod 3600 div 60) as text
set mText to text ((length of mText) - 1) thru -1 of mText
set sText to "0" & ((time of (curDay)) mod 3600 mod 60) as text
set sText to text ((length of sText) - 1) thru -1 of sText
set diffToGMT to "+0" & ((((time to GMT) / 3600) as integer) * 100) as text
set aRes to dayText & ", " & dateText & " " & monText & " " & yearText & " " & hText & ":" & mText & ":" & sText & " " & diffToGMT
return aRes
end ret_rfc822date
on ret_rfc822date()
set curDay to current date
set dayText to text 1 thru 3 of (weekday of (curDay) as text)
set dateText to "00" & day of curDay
set dateText to text ((length of dateText) - 1) thru -1 of dateText
set monText to text 1 thru 3 of (month of (curDay) as text)
set yearText to year of (curDay)
set hText to "0" & ((time of (curDay)) div 3600) as text
set hText to text ((length of hText) - 1) thru -1 of hText
set mText to "0" & ((time of (curDay)) mod 3600 div 60) as text
set mText to text ((length of mText) - 1) thru -1 of mText
set sText to "0" & ((time of (curDay)) mod 3600 mod 60) as text
set sText to text ((length of sText) - 1) thru -1 of sText
set diffToGMT to "+0" & ((((time to GMT) / 3600) as integer) * 100) as text
set aRes to dayText & ", " & dateText & " " & monText & " " & yearText & " " & hText & ":" & mText & ":" & sText & " " & diffToGMT
return aRes
end ret_rfc822date
こんなに書いた(ーー;;;;;;;;;
んーーーーーーーーーーーーーーー。Leopardでは対応していてほしい(ーー;;;;
後日談:などと書いていたら、いろいろレスがついて…………
ret_rfc822date() of me
--RSS用のRFC822形式の日付を返す
on ret_rfc822date()
set aRes to do shell script "ruby -r 'time' -e 'puts Time.now.rfc822'"
return aRes
end ret_rfc822date
--RSS用のRFC822形式の日付を返す
on ret_rfc822date()
set aRes to do shell script "ruby -r 'time' -e 'puts Time.now.rfc822'"
return aRes
end ret_rfc822date
こんなに短くなった(ーー;;;;