[ABAP] Zeit zu Zeit und Datum rechnen

DATA: lv_sdate TYPE d.
DATA: lv_stime TYPE t.

* akt. Datum und Zeit
lv_sdate = sy-datum.
lv_stime = sy-uzeit.

* 10:00:00Uhr
DATA: lv_addtime TYPE t VALUE '100000'.

DATA: lv_edate TYPE d.
DATA: lv_etime TYPE t.

START-OF-SELECTION.

* Zeitwerte addieren
  CALL FUNCTION 'C14B_ADD_TIME'
    EXPORTING
      i_starttime = lv_stime
      i_startdate = lv_sdate
      i_addtime   = lv_addtime
    IMPORTING
      e_endtime   = lv_etime
      e_enddate   = lv_edate.

  WRITE: / lv_sdate, lv_stime.
  WRITE: / lv_edate, lv_etime.

[JavaScript] Einfacher Timer

<!doctype html>
<html lang="de">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Timer demo</title>
  </head>
  <body>
    <script>
      'use strict';  
      (function () {
        function timer() {
          let st = Date.now();
          // Intervall 100ms
          setInterval(function() {
            let el = Date.now() - st;
            console.log((el / 1000).toFixed(1));
          }, 100);
        }

        document.addEventListener('DOMContentLoaded', timer);
      }());
    </script>
  </body>
</html>

[JavaScript] Date: Datum und Zeit

// https://www.w3schools.com/jsref/jsref_obj_date.asp
// https://javascript.info/date

// akt. Datum + Uhrzeit
let dt_curr = new Date();
console.log(dt_curr.toString());

// Datum: 31.12.2018, Uhrzeit: 12:10:20,0
// Monat startet mit Index 0!
let d = new Date(2018, 11, 31, 12, 10, 20, 0);

// Mon Dec 31 2018 12:10:20 GMT+0100
console.log(d.toString());
// Mon, 31 Dec 2018 11:10:20 GMT
console.log(d.toUTCString());
// 2018-12-31T11:10:20.000Z
console.log(d.toISOString());
// 31.12.2018, 12:10:20
console.log(d.toLocaleString('de-DE'));
// 31.12.2018
console.log(d.toLocaleDateString('de-DE'));
// 12:10:20
console.log(d.toLocaleTimeString('de-DE'));

// Anzahl Millisekunden, seit 01.01.1970 00:00:00 UTC
console.log(Date.now());

[ABAP] UTC-Zeit (TIMESTAMP) in Datum (d) und Uhrzeit (t) splitten

DATA: lv_date TYPE d.
DATA: lv_time TYPE t.
DATA: lv_utc TYPE timestamp.

GET TIME STAMP FIELD lv_utc.

* Zeitzohne bleibt UTC, Timestamp wird also ohne Umrechnung der Zone gesplittet
CONVERT TIME STAMP lv_utc TIME ZONE 'UTC' INTO DATE lv_date TIME lv_time.

WRITE: / |UTC: { lv_utc TIMESTAMP = USER }|.
WRITE: / |UTC-Datum: { lv_date DATE = USER }|.
WRITE: / |UTC-Zeit: { lv_time TIME = USER }|.

[ABAP] UTC-Zeit (TIMESTAMP) in Systemzeit wandeln

DATA: lv_utc TYPE timestamp.
DATA: lv_date TYPE d.
DATA: lv_time TYPE t.

START-OF-SELECTION.

  GET TIME STAMP FIELD lv_utc.

  TRY.
      cl_abap_tstmp=>systemtstmp_utc2syst( EXPORTING
                                             utc_tstmp = lv_utc
                                           IMPORTING
                                             syst_date = lv_date
                                             syst_time = lv_time  ).

      WRITE: / |UTC: { lv_utc TIMESTAMP = USER }|.
      WRITE: / |System-Datum: { lv_date DATE = USER }|.
      WRITE: / |System-Zeit: { lv_time TIME = USER }|.

    CATCH cx_root INTO DATA(e_text).
      WRITE: / e_text->get_text( ).
  ENDTRY.

[ABAP] Systemzeit in UTC-Zeit (TIMESTAMP) wandeln

DATA: lv_utc TYPE timestamp.
DATA: lv_date TYPE d.
DATA: lv_time TYPE t.

START-OF-SELECTION.

  lv_date = sy-datum.
  lv_time = sy-uzeit.

  TRY.
      cl_abap_tstmp=>systemtstmp_syst2utc( EXPORTING
                                             syst_date = lv_date
                                             syst_time = lv_time
                                           IMPORTING
                                             utc_tstmp = lv_utc ).

      WRITE: / |UTC: { lv_utc TIMESTAMP = USER }|.
      WRITE: / |System-Datum: { lv_date DATE = USER }|.
      WRITE: / |System-Zeit: { lv_time TIME = USER }|.

    CATCH cx_root INTO DATA(e_text).
      WRITE: / e_text->get_text( ).
  ENDTRY.