Skip to content

Commit 7a0d70f

Browse files
committed
Convert Changeset timestamp to UTC before saving
This fixes display of the commit time in the wrong timezone when the original commit received from source control contains timezone info as was the case with SourceGitea plugin. Fixes#419 (originally reported in PR #416)
1 parent 3132add commit 7a0d70f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Source/Source.API.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,10 @@ function save() {
954954
# Commit timestamp: can't use DATE_ATOM format to insert datetime,
955955
# as MySQL < 8.0.19 does not support specifying timezone
956956
# @see https://dev.mysql.com/doc/refman/8.0/en/datetime.html
957-
$t_timestamp = $this->timestamp->format( 'Y-m-d H:i:s' );
957+
# so we convert the timestamp to UTC first.
958+
$t_timestamp = $this->timestamp
959+
->setTimezone( newDateTimeZone( 'UTC' ) )
960+
->format( 'Y-m-d H:i:s' );
958961

959962
if ( 0 == $this->id ) { # create
960963
$t_query = "INSERT INTO $t_changeset_table ( repo_id, revision, parent, branch, user_id,

0 commit comments

Comments
 (0)
close