ruby
のTime.parse
の値をJST
で表示したいです。
以下のように、2018-06-01T17:21:17.916124+00:00
をTime.parse
で読み込んでJST
で表示しようとしているのですが、
2018-06-01 17:21:17 +0000
となってしまいうまく行きません。
どなたかお詳しい方お知恵をお借り出来ませんでしょうか?
よろしくお願い致します。
環境
macOS High Sierra 10.13.4
ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]
ファイル名
localtime.rb
(以下ページを参考にして改変して作成しています)
Sooey
ruby
1 2#!/usr/bin/env ruby 3# -*- coding: utf-8 -*- 4require 'time' 5 6pattern = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{6}+\d{2}:\d{2})(.+)$/ 7ARGF.each { |line| puts "#{Time.parse($1)}#{$2}" if line =~ pattern }
# heroku logs | tail -5 2018-06-01T17:21:17.916124+00:00 heroku[web.1]: Idling 2018-06-01T17:21:17.916124+00:00 heroku[web.1]: State changed from up to down 2018-06-01T17:21:18.740095+00:00 app[web.1]: Going down, terminating child processes... 2018-06-01T17:21:18.733059+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2018-06-01T17:21:18.794399+00:00 heroku[web.1]: Process exited with status 143
# heroku logs | tail -5 | ruby localtime.rb 2018-06-01 17:21:17 +0000 heroku[web.1]: Idling 2018-06-01 17:21:17 +0000 heroku[web.1]: State changed from up to down 2018-06-01 17:21:18 +0000 app[web.1]: Going down, terminating child processes... 2018-06-01 17:21:18 +0000 heroku[web.1]: Stopping all processes with SIGTERM 2018-06-01 17:21:18 +0000 heroku[web.1]: Process exited with status 143
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/06/01 18:24