Revision: 27539
          http://sourceforge.net/p/bibdesk/svn/27539
Author:   hofman
Date:     2022-06-03 16:47:50 +0000 (Fri, 03 Jun 2022)
Log Message:
-----------
Set date added and modified for import using a custom function, don't need to 
go through all update handling

Modified Paths:
--------------
    trunk/bibdesk/BibDocument.m
    trunk/bibdesk/BibItem.h
    trunk/bibdesk/BibItem.m

Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2022-06-03 16:21:58 UTC (rev 27538)
+++ trunk/bibdesk/BibDocument.m 2022-06-03 16:47:50 UTC (rev 27539)
@@ -1972,9 +1972,10 @@
 - (void)markAsImported {
     [self setFileURL:nil];
     // set date-added for imports
-    NSString *importDate = [[NSDate date] standardDescription];
+    NSDate *importDate = [NSDate date];
+    NSString *importDateDescription = [importDate standardDescription];
     for (BibItem *pub in publications)
-        [pub setField:BDSKDateAddedString toValue:importDate];
+        [pub setDateAdded:importDate description:importDateDescription];
     [[self undoManager] removeAllActions];
     // mark as dirty, since we've changed the content
     [self updateChangeCount:NSChangeDone];
@@ -2180,9 +2181,10 @@
     NSUserDefaults *sud = [NSUserDefaults standardUserDefaults];
     
     // set Date-Added to the current date, since unarchived items will have 
their own (incorrect) date
-    NSString *importDate = [[NSDate date] standardDescription];
+    NSDate *importDate = [NSDate date];
+    NSString *importDateDescription = [importDate standardDescription];
     for (pub in newPubs)
-        [pub setField:BDSKDateAddedString toValue:importDate];
+        [pub setDateAdded:importDate description:importDateDescription];
     
     if ((options & BDSKImportSelectLibrary))
         [self selectLibraryGroup:nil];    

Modified: trunk/bibdesk/BibItem.h
===================================================================
--- trunk/bibdesk/BibItem.h     2022-06-03 16:21:58 UTC (rev 27538)
+++ trunk/bibdesk/BibItem.h     2022-06-03 16:47:50 UTC (rev 27539)
@@ -437,6 +437,8 @@
 @property (nonatomic, readonly) NSDate *dateAdded;
 @property (nonatomic, readonly) NSDate *dateModified;
 
+- (void)setDateAdded:(NSDate *)date description:(NSString *)dateDescription;
+
 /*!
        @method     setPubType:withModDate:
        @abstract   Basic setter for the publication type, with undo. Sets up 
the fields if necessary.

Modified: trunk/bibdesk/BibItem.m
===================================================================
--- trunk/bibdesk/BibItem.m     2022-06-03 16:21:58 UTC (rev 27538)
+++ trunk/bibdesk/BibItem.m     2022-06-03 16:47:50 UTC (rev 27539)
@@ -575,6 +575,13 @@
        return YES;
 }
 
+- (void)setDateAdded:(NSDate *)date description:(NSString *)dateDescription {
+    [pubFields setObject:dateDescription forKey:BDSKDateAddedString];
+    [pubFields setObject:dateDescription forKey:BDSKDateModifiedString];
+    [self setDateAdded:date];
+    [self setDateModified:date];
+}
+
 #pragma mark Archiving
 
 + (NSData *)archivedPublications:(NSArray *)array {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to