@@ -303,13 +303,13 @@ public bool ShowAsDateTime
303303 set => SetValue ( ShowAsDateTimeProperty , value ) ;
304304 }
305305
306- public static readonly StyledProperty < ulong > TimestampProperty =
307- AvaloniaProperty . Register < CommitTimeTextBlock , ulong > ( nameof ( Timestamp ) ) ;
306+ public static readonly StyledProperty < bool > UseAuthorTimeProperty =
307+ AvaloniaProperty . Register < CommitTimeTextBlock , bool > ( nameof ( UseAuthorTime ) , true ) ;
308308
309- public ulong Timestamp
309+ public bool UseAuthorTime
310310 {
311- get => GetValue ( TimestampProperty ) ;
312- set => SetValue ( TimestampProperty , value ) ;
311+ get => GetValue ( UseAuthorTimeProperty ) ;
312+ set => SetValue ( UseAuthorTimeProperty , value ) ;
313313 }
314314
315315 protected override Type StyleKeyOverride => typeof ( TextBlock ) ;
@@ -318,7 +318,7 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
318318 {
319319 base . OnPropertyChanged ( change ) ;
320320
321- if ( change . Property == TimestampProperty )
321+ if ( change . Property == UseAuthorTimeProperty )
322322 {
323323 SetCurrentValue ( TextProperty , GetDisplayText ( ) ) ;
324324 }
@@ -347,6 +347,12 @@ protected override void OnUnloaded(RoutedEventArgs e)
347347 StopTimer ( ) ;
348348 }
349349
350+ protected override void OnDataContextChanged ( EventArgs e )
351+ {
352+ base . OnDataContextChanged ( e ) ;
353+ SetCurrentValue ( TextProperty , GetDisplayText ( ) ) ;
354+ }
355+
350356 private void StartTimer ( )
351357 {
352358 if ( _refreshTimer != null )
@@ -376,30 +382,35 @@ private void StopTimer()
376382
377383 private string GetDisplayText ( )
378384 {
385+ var commit = DataContext as Models . Commit ;
386+ if ( commit == null )
387+ return string . Empty ;
388+
389+ var timestamp = UseAuthorTime ? commit . AuthorTime : commit . CommitterTime ;
379390 if ( ShowAsDateTime )
380- return DateTime . UnixEpoch . AddSeconds ( Timestamp ) . ToLocalTime ( ) . ToString ( "yyyy/MM/dd HH:mm:ss" ) ;
391+ return DateTime . UnixEpoch . AddSeconds ( timestamp ) . ToLocalTime ( ) . ToString ( "yyyy/MM/dd HH:mm:ss" ) ;
381392
382393 var today = DateTime . Today ;
383- var committerTime = DateTime . UnixEpoch . AddSeconds ( Timestamp ) . ToLocalTime ( ) ;
394+ var localTime = DateTime . UnixEpoch . AddSeconds ( timestamp ) . ToLocalTime ( ) ;
384395
385- if ( committerTime >= today )
396+ if ( localTime >= today )
386397 {
387398 var now = DateTime . Now ;
388- var timespan = now - committerTime ;
399+ var timespan = now - localTime ;
389400 if ( timespan . TotalHours > 1 )
390401 return App . Text ( "Period.HoursAgo" , ( int ) timespan . TotalHours ) ;
391402
392403 return timespan . TotalMinutes < 1 ? App . Text ( "Period.JustNow" ) : App . Text ( "Period.MinutesAgo" , ( int ) timespan . TotalMinutes ) ;
393404 }
394405
395- var diffYear = today . Year - committerTime . Year ;
406+ var diffYear = today . Year - localTime . Year ;
396407 if ( diffYear == 0 )
397408 {
398- var diffMonth = today . Month - committerTime . Month ;
409+ var diffMonth = today . Month - localTime . Month ;
399410 if ( diffMonth > 0 )
400411 return diffMonth == 1 ? App . Text ( "Period.LastMonth" ) : App . Text ( "Period.MonthsAgo" , diffMonth ) ;
401412
402- var diffDay = today . Day - committerTime . Day ;
413+ var diffDay = today . Day - localTime . Day ;
403414 return diffDay == 1 ? App . Text ( "Period.Yesterday" ) : App . Text ( "Period.DaysAgo" , diffDay ) ;
404415 }
405416
0 commit comments