Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git

Displays timezone on commit page

Author Dave Jarvis <email>
Date 2026-02-20 17:43:03 GMT-0800
Commit 8519fa3df1dc1ad1c1c7f6f0dde70988fb23d702
Parent 9694dda
pages/DiffPage.php
$authorName = htmlspecialchars( $m[1] ) . ' &lt;email&gt;';
$timestamp = (int)$m[2];
- $pattern = '/([-+])(\d{2})(\d{2})/';
- $tzString = preg_replace( $pattern, '$1$2:$3', $m[3] );
$dt = new DateTime( '@' . $timestamp );
+ $offsetStr = $m[3];
+ $sign = $offsetStr[0] === '-' ? -1 : 1;
+ $hours = (int)substr( $offsetStr, 1, 2 );
+ $mins = (int)substr( $offsetStr, 3, 2 );
+ $offsetSecs = $sign * ( $hours * 3600 + $mins * 60 );
+ $tzName = timezone_name_from_abbr( '', $offsetSecs, 1 ) ?:
+ timezone_name_from_abbr( '', $offsetSecs, 0 );
- $dt->setTimezone( new DateTimeZone( $tzString ) );
+ if( $tzName !== false ) {
+ $dt->setTimezone( new DateTimeZone( $tzName ) );
+ } else {
+ $pattern = '/([-+])(\d{2})(\d{2})/';
+ $tzString = preg_replace( $pattern, '$1$2:$3', $offsetStr );
- $commitDate = $dt->format( 'Y-m-d H:i:s P' );
+ $dt->setTimezone( new DateTimeZone( $tzString ) );
+ }
+
+ $commitDate = $dt->format( 'Y-m-d H:i:s T' );
}
Delta 16 lines added, 4 lines removed, 12-line increase