Skip to content

Commit 1c540a3

Browse files
committed
Display the backup time in a local timezone.
Before this change, the "--list" report showed the backup time in a UTC timezone. This was confusing and unexpected. Now the backup time is always displayed in the local timezone.
1 parent e440063 commit 1c540a3

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/ios_backup_extractor.pl

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,8 @@ ($all_devices_backup_hashref)
297297
my $device_backup_info_hashref = $all_devices_backup_hashref->{$serial};
298298
$name = $device_backup_info_hashref->{Info}{'Display Name'};
299299
$device = $device_backup_info_hashref->{Info}{'Product Name'},
300-
$backup_date = ($_ = $device_backup_info_hashref->{Info}{'Last Backup Date'})
301-
? s/\A(\d{4})-(\d\d)-(\d\d)
302-
T(\d\d)\:(\d\d)\:(\d\d(?:\.\d+)?)Z\z/$1-$2-$3 $4:$5/xr
303-
: q{Unknown};
300+
$backup_date = utcTimeToLocaltime (
301+
$device_backup_info_hashref->{Info}{'Last Backup Date'});
304302
$encrypted = $device_backup_info_hashref->{Manifest}{IsEncrypted}
305303
? 'Yes'
306304
: 'No';
@@ -313,6 +311,21 @@ ($all_devices_backup_hashref)
313311

314312
# ----------------------------------------------------------------
315313

314+
sub utcTimeToLocaltime ($time)
315+
{
316+
# $time is in format '2023-11-03T17:18:33Z'
317+
$time =~ /\A \d{4}-\d\d-\d\d T \d\d\:\d\d\:\d\d (?:\.\d+)? Z \z/x
318+
or return 'Unknown';
319+
320+
my $utc_tp = Time::Piece->strptime ($time, '%FT%TZ')
321+
or return 'Unknown';
322+
323+
my $local_tp = Time::Piece->localtime ($utc_tp->epoch);
324+
return $local_tp->strftime ('%Y-%m-%d %H:%M');
325+
}
326+
327+
# ----------------------------------------------------------------
328+
316329
sub displayBackupListLong ($all_devices_backup_hashref)
317330
{
318331
my $counter = 1;

0 commit comments

Comments
 (0)