]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CC-397: Fixed BP date ranges to be based off 1950 not the curr year
authorcesarvh <cesarv.h@berkeley.edu>
Wed, 13 Mar 2019 19:28:20 +0000 (12:28 -0700)
committercesarvh <cesarv.h@berkeley.edu>
Tue, 19 Mar 2019 19:45:07 +0000 (12:45 -0700)
services/structureddate/structureddate/src/main/java/org/collectionspace/services/structureddate/antlr/ANTLRStructuredDateEvaluator.java
services/structureddate/structureddate/src/test/resources/test-dates.yaml

index bfa622ff303ebc6137aa9b10053748c8b9e886e1..89e82f3ea0582e2eedddd9cb0d7f3355108c8c88 100644 (file)
@@ -105,6 +105,7 @@ public class ANTLRStructuredDateEvaluator extends StructuredDateBaseListener imp
         * The result of the evaluation.
         */
        protected StructuredDateInternal result;
+       private final int BP_ZERO_YEAR = 1950;
 
        /**
         * The operation stack. The parse listener methods that are implemented here
@@ -1244,15 +1245,10 @@ public class ANTLRStructuredDateEvaluator extends StructuredDateBaseListener imp
                if (ctx.exception != null) return;
 
                Integer adjustmentDate = (Integer) stack.pop();
-               Integer mainYear = (Integer) stack.pop();
+               Integer mainYear = (Integer) stack.pop(); 
 
-               Integer upperBound = mainYear + adjustmentDate;
-               Integer lowerBound = mainYear - adjustmentDate;
-
-               Integer currentYear = DateUtils.getCurrentDate().getYear();
-
-               Integer earliestYear = currentYear - upperBound;
-               Integer latestYear = currentYear - lowerBound ;
+               Integer earliestYear = (BP_ZERO_YEAR - mainYear) - adjustmentDate;
+               Integer latestYear = (BP_ZERO_YEAR - mainYear) + adjustmentDate;
 
                // If negative, then BC, else AD
                Era earliestEra = earliestYear < 0 ? Era.BCE : Era.CE;
index bd9d8d26ec0fe21ec2f0981ae5bbac369c3430a1..344737e8fb7a81b2af5a908ec482db2a36ce4cd5 100644 (file)
                                          earliestSingleDate: [9,     7, 31, CE]
                                          latestDate:         [1996,  4,  1, CE]
 
-  "1200±50 BP":                          # Uncalibrated date with ± symbol, with CE
-                                         earliestSingleDate: "uncalibrated earliest date"
-                                         latestDate:         "uncalibrated latest date"
+  "1200±50 BP":                          # Uncalibrated date with ± symbol
+                                         earliestSingleDate: [700, 1, 1, CE]
+                                         latestDate:         [800, 12, 31, CE ]
 
   "3100 +/- 150 BP":                     # Uncalibrated date with +/- instead of ± symbol
-                                         earliestSingleDate: "uncalibrated earliest date"
-                                         latestDate:         "uncalibrated latest date"
+                                         earliestSingleDate: [1300, 1, 1, BCE]
+                                         latestDate:         [1000, 12, 31, BCE]
 
   "3100+/-150 BP":                       # Uncalibrated date with +/- instead of ± symbol, no spaces
-                                         earliestSingleDate: "uncalibrated earliest date"
-                                         latestDate:         "uncalibrated latest date"
+                                         earliestSingleDate: [1300, 1, 1, BCE]
+                                         latestDate:         [1000, 12, 31, BCE]
 
   "3100+/-150 years BP":                 # Uncalibrated date with 'years' in it
-                                         earliestSingleDate: "uncalibrated earliest date"
-                                         latestDate:         "uncalibrated latest date"
+                                         earliestSingleDate: [1300, 1, 1, BCE]
+                                         latestDate:         [1000, 12, 31, BCE]
 
   "3,100+/-150 years BP":                # Uncalibrated date with 'years' in it as well as with a comma
-                                         earliestSingleDate: "uncalibrated earliest date"
-                                         latestDate:         "uncalibrated latest date"
+                                         earliestSingleDate: [1300, 1, 1, BCE]
+                                         latestDate:         [1000, 12, 31, BCE]
 
   "2000±100 BP":                         # Uncalibrated date with BCE and AD mix
-                                         earliestSingleDate: "uncalibrated earliest date"
-                                         latestDate:         "uncalibrated latest date"
+                                         earliestSingleDate: [150, 1, 1, BCE]
+                                         latestDate:         [50, 12, 31, CE]
 
   "5580-5460 BC":                        # Calibrated date with commas
                                          earliestSingleDate: [5580,  1, 1, BCE]
 
   '01-IV-2017 BCE':                          # Day-Month-Year with roman numeral as month, with Era
                                           earliestSingleDate: [2017, 4, 1, BCE]  
+  
+  # '12 june 1942 - 13 june 1943':            # hyphenatedRange, date with comma'd numbers
+  #                                        earliestSingleDate: [1942,  6,  12, CE]
+  #                                        latestDate:         [1942,  6,  13, CE]
 
 # -------------------------------------------------------------------------------------------------------
 # Invalid dates