JBAS-1437 Backstage update authority 005 date values
authorBill Erickson <berickxx@gmail.com>
Wed, 26 Oct 2016 16:30:32 +0000 (12:30 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/backstage/process-backstage-files.pl

index bf1aebb..ca69b52 100755 (executable)
@@ -309,6 +309,8 @@ sub handle_modified_auths {
 
     while (my $record = $marc_batch->next()) {
 
+        modify_auth_005($record);
+
         my @matches = find_matching_auths($record);
         push(@matches, find_replaced_auths($record));
 
@@ -322,6 +324,24 @@ sub handle_modified_auths {
    }
 }
 
+# Update the 005 field to the current date
+sub modify_auth_005 {
+    my $record = shift;
+    my $field_005 = $record->field('005');
+
+    # MARC 005-formatted date value
+    my $now_date = DateTime->now(
+        time_zone => 'local')->strftime('%Y%m%d%H%M%S.0');
+
+    if ($field_005) {
+        $field_005->update($now_date);
+
+    } else {
+        $field_005 = MARC::Field->new('005', $now_date);
+        $record->insert_fields_ordered($field_005);
+    }
+}
+
 
 sub update_auth {
     my $marcxml = shift;