Manuel,
I've decompiled the classes concerned, and it seems to involve the GregorianCalendar:
public static final Numeric date_of_integer(Variable variable)
{
long l = variable.toLong();
GregorianCalendar gregoriancalendar = new GregorianCalendar(1600, 11, 31);
gregoriancalendar.add(5, (int)l);
return new Numeric(Utilities.format(gregoriancalendar.get(1), 4) + Utilities.format(gregoriancalendar.get(2) + 1, 2) + Utilities.format(gregoriancalendar.get(5), 2));
}
public static final Numeric day_of_integer(Variable variable)
{
long l = variable.toLong();
GregorianCalendar gregoriancalendar = new GregorianCalendar(1600, 11, 31);
gregoriancalendar.add(5, (int)l);
return new Numeric(Utilities.format(gregoriancalendar.get(1), 4) + Utilities.format(gregoriancalendar.get(6), 3));
}
public static final Numeric integer_of_date(Variable variable)
{
String s = variable.toNumericString();
if(s.length() < 8)
s = "00000000" + s;
if(s.length() > 8)
s = s.substring(s.length() - 8);
long l1 = 0L;
try
{
int j = Integer.parseInt(s.substring(0, 4));
int k = Integer.parseInt(s.substring(4, 6));
int l = Integer.parseInt(s.substring(6, 8));
GregorianCalendar gregoriancalendar = new GregorianCalendar(j, k - 1, l);
long l3 = gregoriancalendar.getTime().getTime() - d.getTime().getTime();
long l4 = 0x36ee80L;
long l2 = (l3 + l4) / (24L * l4);
return new Numeric(l2);
}
catch(Exception exception)
{
return new Numeric();
}
}
public static final Numeric integer_of_day(Variable variable)
{
String s = variable.toNumericString();
if(s.length() < 7)
s = "0000000" + s;
if(s.length() > 7)
s = s.substring(s.length() - 7);
try
{
int j = Integer.parseInt(s.substring(0, 4));
int k = Integer.parseInt(s.substring(4, 7));
j -= 1601;
return new Numeric(((j * 365 + j / 4) - j / 100) + j / 400 + k);
}
catch(Exception exception)
{
return new Numeric();
}
}
But I think I'll pass the problem on to PerCobol, and go for a less complicated solution to check a date is valid.
Thanks for your assistance.
Patrick
PS: my office phone is 02 547 58 59