Skip to content

Commit a970a65

Browse files
authored
Added funcCombinedDatetime() in CobolIntrinsic.java (#207)
1 parent 293dbb9 commit a970a65

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

libcobj/src/jp/osscons/opensourcecobol/libcobj/common/CobolIntrinsic.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,4 +1689,39 @@ public static AbstractCobolField funcNational(AbstractCobolField srcfield) {
16891689
currField.getDataStorage().memcpy(pdata, ndata);
16901690
return currField;
16911691
}
1692+
1693+
public static AbstractCobolField funcCombinedDatetime(
1694+
AbstractCobolField srcdays, AbstractCobolField srctime) {
1695+
int srdays;
1696+
int srtime;
1697+
String str;
1698+
byte[] buff = new byte[12];
1699+
1700+
CobolFieldAttribute attr =
1701+
new CobolFieldAttribute(CobolFieldAttribute.COB_TYPE_NUMERIC_DISPLAY, 12, 5, 0, null);
1702+
AbstractCobolField field = CobolFieldFactory.makeCobolField(12, (CobolDataStorage) null, attr);
1703+
makeFieldEntry(field);
1704+
CobolRuntimeException.setException(0);
1705+
srdays = srcdays.getInt();
1706+
if (srdays < 1 || srdays > 3067671) {
1707+
CobolRuntimeException.setException(CobolExceptionId.COB_EC_ARGUMENT_FUNCTION);
1708+
currField.getDataStorage().memset(0, 12);
1709+
return currField;
1710+
}
1711+
srtime = srctime.getInt();
1712+
if (srtime < 1 || srtime > 86400) {
1713+
CobolRuntimeException.setException(CobolExceptionId.COB_EC_ARGUMENT_FUNCTION);
1714+
currField.getDataStorage().memset(0, 12);
1715+
return currField;
1716+
}
1717+
str = String.format("%7d%5d", srdays, srtime);
1718+
buff = str.getBytes();
1719+
for (int i = 0; i < 12; i++) {
1720+
if (buff[i] == 32) {
1721+
buff[i] = 48;
1722+
}
1723+
}
1724+
currField.getDataStorage().memcpy(buff);
1725+
return currField;
1726+
}
16921727
}

tests/run.src/functions.at

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ AT_CHECK([java prog], [0],
180180
AT_CLEANUP
181181

182182
AT_SETUP([FUNCTION COMBINED-DATETIME])
183-
AT_CHECK([${SKIP_TEST}])
184183

185184
AT_DATA([prog.cob], [
186185
IDENTIFICATION DIVISION.

0 commit comments

Comments
 (0)