Skip to content

Commit bca6344

Browse files
committed
C & Internal: Fix inconsistencies
1 parent 6cf53a2 commit bca6344

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

N2A/src/gov/sandia/n2a/backend/c/runtime/holder.tcc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,6 +2157,14 @@ convertDate (const String & field, T defaultValue)
21572157
}
21582158
valid = year > 12 && month <= 12;
21592159
}
2160+
2161+
// Until we have better hints from user, assume 2-digit year should have century offset.
2162+
// TODO: fix Y2K bug ...
2163+
if (year < 100)
2164+
{
2165+
if (year > 50) year += 1900;
2166+
else year += 2000;
2167+
}
21602168
}
21612169
}
21622170

N2A/src/gov/sandia/n2a/language/AccessElement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public Type eval (Instance instance)
180180
double row = ((Scalar) operands[1].eval (instance)).value;
181181
double column = 0;
182182
if (operands.length > 2) column = ((Scalar) operands[2].eval (instance)).value;
183-
return new Scalar (A.get (row, column, Matrix.INTERPOLATE)); // This access function does bounds check.
183+
return new Scalar (A.get (row, column, Matrix.ZEROS)); // This access function does bounds check.
184184
}
185185
catch (ClassCastException e)
186186
{

N2A/src/gov/sandia/n2a/language/function/Input.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,19 @@ else if (dateString.contains ("-")) // Other parts of date/time are present
561561
}
562562
else if (dateString.contains ("/")) // Conventional date
563563
{
564-
// TODO: add keyword parameter for correct date format, such as "mdy" or "ymd".
565-
format = new SimpleDateFormat ("MM/dd/yyyy");
564+
String pieces[] = dateString.split ("/");
565+
if (pieces.length == 3)
566+
{
567+
if (pieces[2].length () > 2)
568+
{
569+
format = new SimpleDateFormat ("MM/dd/yyyy");
570+
}
571+
else
572+
{
573+
// TODO: add keyword parameter for correct date format, such as "mdy" or "ymd".
574+
format = new SimpleDateFormat ("MM/dd/yy");
575+
}
576+
}
566577
}
567578
if (format != null)
568579
{

N2A/src/gov/sandia/n2a/language/type/Matrix.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ public double get (int row)
5757
return get (row, 0);
5858
}
5959

60-
public static final int REPLICATE = 0; // truncates coordinates; a read out of bounds returns nearest element
61-
public static final int ZEROS = 1; // truncates coordinates; a read out of bounds returns zero
60+
public static final int REPLICATE = 0; // truncates coordinates; an out-of-bounds read returns nearest element
61+
public static final int ZEROS = 1; // truncates coordinates; an out-of-bounds read returns zero
6262
public static final int UNITMAP = 2; // applies offset and scaling for unitmap()
63-
public static final int INTERPOLATE = 3; // interpolates non-integer coordinates; a read out of bounds extrapolates nearest elements
63+
public static final int INTERPOLATE = 3; // interpolates non-integer coordinates; an out-of-bounds read extrapolates nearest elements
6464

6565
public double get (double row, double column, int mode)
6666
{

0 commit comments

Comments
 (0)