File tree Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -663,6 +663,14 @@ class lcl_json_to_abap definition final.
663
663
raising
664
664
zcx_ajson_error.
665
665
666
+ methods to_time
667
+ IMPORTING
668
+ iv_value TYPE z2ui5_if_ajson_types=>ty_node-value
669
+ RETURNING
670
+ VALUE (rv_result ) TYPE t
671
+ RAISING
672
+ z2ui5_cx_ajson_error.
673
+
666
674
private section .
667
675
668
676
types :
@@ -977,6 +985,8 @@ class lcl_json_to_abap implementation.
977
985
" TODO: check type ?
978
986
if is_node_type-type_kind = lif_kind=>date and is_node-value is not initial .
979
987
<container> = to_date( is_node-value ).
988
+ elseif is_node_type-type_kind = lif_kind=>time and is_node-value is not initial .
989
+ <container> = to_time( is_node-value ).
980
990
elseif is_node_type-type_kind = lif_kind=>packed and is_node-value is not initial .
981
991
<container> = to_timestamp( is_node-value ).
982
992
else .
@@ -1086,6 +1096,22 @@ class lcl_json_to_abap implementation.
1086
1096
1087
1097
endmethod .
1088
1098
1099
+ method to_time .
1100
+
1101
+ DATA lv_h TYPE c LENGTH 2 .
1102
+ DATA lv_m TYPE c LENGTH 2 .
1103
+ DATA lv_s TYPE c LENGTH 2 .
1104
+
1105
+ FIND FIRST OCCURRENCE OF REGEX '^(\d{2}):(\d{2}):(\d{2})(T|$)' "#EC NOTEXT
1106
+ IN iv_value
1107
+ SUBMATCHES lv_h lv_m lv_s.
1108
+ IF sy -subrc <> 0 .
1109
+ z2ui5_cx_ajson_error=>raise( 'Unexpected time format' ).
1110
+ ENDIF .
1111
+ CONCATENATE lv_h lv_m lv_s INTO rv_result.
1112
+
1113
+ endmethod .
1114
+
1089
1115
endclass .
1090
1116
1091
1117
**********************************************************************
Original file line number Diff line number Diff line change @@ -1457,7 +1457,9 @@ class ltcl_json_to_abap definition
1457
1457
methods to_abap_corresponding_pub_neg
1458
1458
for testing
1459
1459
raising zcx_ajson_error.
1460
-
1460
+ methods to_abap_time
1461
+ FOR TESTING
1462
+ reaising cx_static_check.
1461
1463
endclass .
1462
1464
1463
1465
class zcl_ajson definition local friends ltcl_json_to_abap .
@@ -1534,6 +1536,28 @@ class ltcl_json_to_abap implementation.
1534
1536
1535
1537
endmethod .
1536
1538
1539
+ METHOD to_abap_time .
1540
+
1541
+ DATA lo_cut TYPE REF TO lcl_json_to_abap.
1542
+ DATA lv_mock TYPE t .
1543
+ DATA lo_nodes TYPE REF TO lcl_nodes_helper.
1544
+
1545
+ CREATE OBJECT lo_nodes.
1546
+ lo_nodes->add( ' | |str |11:11:11| ' ).
1547
+
1548
+ CREATE OBJECT lo_cut.
1549
+ lo_cut->to_abap(
1550
+ EXPORTING
1551
+ it_nodes = lo_nodes->sorted( )
1552
+ CHANGING
1553
+ c_container = lv_mock ).
1554
+
1555
+ cl_abap_unit_assert=>assert_equals(
1556
+ act = lv_mock
1557
+ exp = '111111' ).
1558
+
1559
+ ENDMETHOD .
1560
+
1537
1561
method to_abap_value .
1538
1562
1539
1563
data lo_cut type ref to lcl_json_to_abap.
You can’t perform that action at this time.
0 commit comments