Skip to content

Commit 04b92b1

Browse files
committed
タイムゾーンに対応(日本人以外使わないでしょ。
1 parent ec92f43 commit 04b92b1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/lib/Backup/Copy/Traits/CopyComment.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ public function copyCommentContent ( $src_comment, $dst_issue_id, $stared = fals
3131

3232
public function addUserInfoIntoCommentHead ( $comment ) {
3333
$creator = $comment->createdUser->name;
34-
$created = substr( $comment->created, 0, 10 ).' '.substr( $comment->created, 11, 5 );
35-
// 失われる情報を本文に残す
34+
35+
$TZ = new \DateTimeZone('Asia/Tokyo');
36+
$created = (new \DateTime( $comment->created))->setTimezone($TZ)->format('Y-m-d H:i');
37+
// 失われる情報を本文に残す
3638
$header = sprintf( <<<EOS
3739
%s / %s
3840
----

src/lib/Backup/Copy/Traits/CopyIssue.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,12 @@ protected function formatIssue ( object $issue_api_result, $add_user_name = true
111111

112112
protected function addUserInfoIntoBody ( object $issue_api_result ) {
113113
$issue = $issue_api_result;
114+
115+
$TZ = new \DateTimeZone('Asia/Tokyo');
114116
$creator = $issue->createdUser->name;
115-
$created = substr( $issue->created, 0, 10 ).' '.substr( $issue->created, 11, 5 );
117+
$created = (new \DateTime($issue->created))->setTimezone($TZ)->format('Y-m-d H:i');
116118
$updator = $issue->updatedUser->name;
117-
$updated = substr( $issue->updated, 0, 10 ).' '.substr( $issue->created, 11, 5 );
119+
$updated = (new \DateTime($issue->updated))->setTimezone($TZ)->format('Y-m-d H:i');
118120
// 失われる情報を本文に残す
119121
$footer = sprintf( <<<EOS
120122

0 commit comments

Comments
 (0)