SlideShare una empresa de Scribd logo
1 de 24
よくやった時間バグ
@i47_rozary
Perl beginners #10
注意 !!
• Time::Piece を中心に語ってます。
• Time::Piece 中心に偏ってます。
• 今までやってしまったバグ
• 今まで周りの人がやったバグ
• だので、具体的 ? かと思います。
自己紹介
• 最近、あんまり Perl 書いてません。
• マネジメントばかりやってるんです orz=3
その前に
YAPC2013 行って来ました。
蟲封祈願 !!
お守りって、 1 年くらいで”お返し”しますよ
ね?
だので、来年お守りをお返ししたら、潜在
バグがワラワラ出てくるんじゃないのかと
…。
ちょっと怖い想像してみた。
で、本題
アジェンダ
• Time::Piece の紹介 ( かるく )
• Time::Piece を使っていて起こすバグと対
策をつらつらと。
Time::Piece 紹介
my $times = time();
my ($sec,$min,$hour,$mday,$month,$year,
$wday,$stime) = localtime($times);
$year += 1900;
print “Year is ”, $year, “n”;
#Year is 2013
Time::Piece 紹介
use Time::Piece;
my $t = localtime;
print “Year is ”, $t->year, “n”;
#Year is 2013
かんた
ん !!
4 行が 2 行に !
値の順番とか気にしない !
Time::Piece 紹介
Perl 5.10 から標準モジュールに入ってま
すぉ。
バグった
話
スタート
バグった 1
my $t1 = Time::Piece->strptime("2013-09-27 17:00:00","%Y-%m%d %H:%M:%S");
say $t1->datetime;
#2013-09-27T17:00:00
my $t2 = localtime->strptime("2013-09-27 17:00:00","%Y-%m%d %H:%M:%S");
say $t2->datetime;
#2013-09-27T17:00:00
バグった 1
今のやつ同じだと思うじゃないですか。
say $t1->epoch;
#1380301200
say $t2->epoch;
#1380268800
タイムゾーンが、ずれてるんで epoch 時間が違ってます。
時間の比較なんかしたらもうね…。
対策
基本的に
localtime->strptime() を使うようにする。
弊社の人間は、恐らく 100% ハマってる。
バグった 2
my $t2 = localtime->strptime("2013-09-27 17:00:00","%Y-%m%d %H:%M:%S");
say $t2->datetime;
#2013-09-27T17:00:00
* Version 1.15
バグった 2
了解、ハッハー !!
localtime 使ってるぜー !!
say $t2->epoch;
#1380301200
Time::Piece で strptime した時の epoch になっとるやない
かー !!
対策

バージョン 1.15 以
前は使うな !!
1.16 の Changes に書いてある。
Implement %z for the internal implementation of strptime().
Unfortunately this doesn't get picked up everywhere, so there are no
tests for it (yet - patches welcome).
バグった 3
# 現在時刻 :2013/09/27 17:00:00
my $t = Time::Piece->new;
$t += ONE_MONTH;
#2013-10-28T04:12:42
バグった 3
27 日が 28 日なっていたりと。
きっかり 1 ヶ月ではない。
対策
年月を見る分には使える。
そらそうだよね、 1 ヶ月の日数ってバラバラだもん。
そこをどう捉えるかは、処理次第だよね ?
その他 バグった
• Time::Piece をテストする時の epoch
• 24 時間 ( 日またぎ ) を超えるプロセスでの
実行
• データリセット時間の設定
まとめ
時間の処理を本番環境で
初めて動かすときは、
リアルタイムで張り付いているといいよ !!
特に日またぎとかね !!

Más contenido relacionado

Destacado

20130725 perl beginners_9
20130725 perl beginners_920130725 perl beginners_9
20130725 perl beginners_9Syun Fuji
 
そんなスクラムなら 止めちまえ
そんなスクラムなら 止めちまえそんなスクラムなら 止めちまえ
そんなスクラムなら 止めちまえSyun Fuji
 
20131128 perl beginners_11_profiler
20131128 perl beginners_11_profiler20131128 perl beginners_11_profiler
20131128 perl beginners_11_profilerSyun Fuji
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionIn a Rocket
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting PersonalKirsty Hulse
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldabaux singapore
 

Destacado (8)

20130725 perl beginners_9
20130725 perl beginners_920130725 perl beginners_9
20130725 perl beginners_9
 
Time band
Time bandTime band
Time band
 
そんなスクラムなら 止めちまえ
そんなスクラムなら 止めちまえそんなスクラムなら 止めちまえ
そんなスクラムなら 止めちまえ
 
20131128 perl beginners_11_profiler
20131128 perl beginners_11_profiler20131128 perl beginners_11_profiler
20131128 perl beginners_11_profiler
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 

Último

論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...Toru Tamaki
 
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムsugiuralab
 
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Yuma Ohgami
 
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdfTSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdftaisei2219
 
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略Ryo Sasaki
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものですiPride Co., Ltd.
 
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A surveyToru Tamaki
 
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)Hiroki Ichikura
 
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNetToru Tamaki
 

Último (9)

論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
 
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システム
 
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
 
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdfTSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdf
 
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものです
 
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey
 
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
 
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet
 

20130927 perlbeginners 10 time-piece