Comparing GET TIME STAMP and sy-datum and sy-uzeit only works if the user is in UTC

This commit is contained in:
fvalves 2024-08-29 09:52:08 +02:00 committed by GitHub
parent 72a1a13033
commit c676fe47f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -84,10 +84,14 @@ CLASS ltcl_field_rules IMPLEMENTATION.
ENDMETHOD. ENDMETHOD.
METHOD fill3. METHOD fill3.
DATA lv_timestamp TYPE timestamp.
CONVERT DATE sy-datum TIME sy-uzeit
INTO TIME STAMP lv_timestamp
TIME ZONE sy-zonlo.
fill_value( fill_value(
iv_rule = zif_abapgit_field_rules=>c_fill_rule-timestamp iv_rule = zif_abapgit_field_rules=>c_fill_rule-timestamp
iv_len = 10 iv_len = 10
iv_exp = |{ sy-datum }{ sy-uzeit(2) }| ). " avoid comparing minutes iv_exp = |{ lv_timestamp DIV 10000 }| ). " avoid comparing minutes
ENDMETHOD. ENDMETHOD.
METHOD fill4. METHOD fill4.
@ -197,7 +201,8 @@ CLASS ltcl_field_rules IMPLEMENTATION.
li_rules TYPE REF TO zif_abapgit_field_rules, li_rules TYPE REF TO zif_abapgit_field_rules,
ls_act TYPE ty_test, ls_act TYPE ty_test,
lt_act TYPE STANDARD TABLE OF ty_test, lt_act TYPE STANDARD TABLE OF ty_test,
lv_ts TYPE string. lv_ts TYPE string,
lv_timestamp TYPE timestamp.
ls_act-key = 1. ls_act-key = 1.
INSERT ls_act INTO TABLE lt_act. INSERT ls_act INTO TABLE lt_act.
@ -235,16 +240,19 @@ CLASS ltcl_field_rules IMPLEMENTATION.
act = ls_act-time(4) act = ls_act-time(4)
exp = sy-uzeit(4) ). " avoid comparing seconds exp = sy-uzeit(4) ). " avoid comparing seconds
CONVERT DATE sy-datum TIME sy-uzeit
INTO TIME STAMP lv_timestamp
TIME ZONE sy-zonlo.
lv_ts = ls_act-ts. lv_ts = ls_act-ts.
lv_ts = lv_ts(12). lv_ts = lv_ts(12).
cl_abap_unit_assert=>assert_equals( cl_abap_unit_assert=>assert_equals(
act = lv_ts act = lv_ts
exp = |{ sy-datum }{ sy-uzeit(4) }| ). " avoid comparing seconds exp = |{ lv_timestamp DIV 100 }| ). " avoid comparing second
lv_ts = ls_act-tl. lv_ts = ls_act-tl.
lv_ts = lv_ts(12). lv_ts = lv_ts(12).
cl_abap_unit_assert=>assert_equals( cl_abap_unit_assert=>assert_equals(
act = lv_ts act = lv_ts
exp = |{ sy-datum }{ sy-uzeit(4) }| ). " avoid comparing seconds exp = |{ lv_timestamp DIV 100 }| ). " avoid comparing seconds
READ TABLE lt_act INTO ls_act INDEX 2. READ TABLE lt_act INTO ls_act INDEX 2.