[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.

[ABAP] string-Formatierungen mit String-Templates

DATA: text TYPE string VALUE 'Text'.
DATA: atext TYPE string VALUE '012345'.
DATA: num TYPE p DECIMALS 3 VALUE '-123.45'.

* Case
WRITE: / |RAW:   { text CASE = RAW }|.   " Text
WRITE: / |LOWER: { text CASE = LOWER }|. " text
WRITE: / |UPPER: { text CASE = UPPER }|. " TEXT

* Align
WRITE: / |LEFT:   ->{ text WIDTH = 20 ALIGN = LEFT }<--|.   " >Text                <
WRITE: / |RIGHT:  ->{ text WIDTH = 20 ALIGN = RIGHT }<--|.  " >                Text<
WRITE: / |CENTER: ->{ text WIDTH = 20 ALIGN = CENTER }<--|. " >        Text        <

* Padding, Auffüllen mit definiertem Zeichen
WRITE: / |PAD: { text ALIGN = LEFT WIDTH = 20 PAD = '_' }|.   " Text________________
WRITE: / |PAD: { text ALIGN = RIGHT WIDTH = 20 PAD = '_' }|.  " ________________Text
WRITE: / |PAD: { text ALIGN = CENTER WIDTH = 20 PAD = '_' }|. " ________Text________

* führende Nullen hinzufügen, ersetzt FUBA 'CONVERSION_EXIT_ALPHA_INPUT'
WRITE: / |ALPHA: { atext WIDTH = 20 ALPHA = IN }|. " 00000000000000012345
* führende Nullen entfernen, ersetzt FUBA 'CONVERSION_EXIT_ALPHA_OUTPUT'
WRITE: / |ALPHA: { atext ALPHA = OUT }|.           " 12345

* Zahlen 1
WRITE: / |RAW:         { num NUMBER = RAW }|.         " -123.45
WRITE: / |USER:        { num NUMBER = USER }|.        " -123,45
WRITE: / |ENVIRONMENT: { num NUMBER = ENVIRONMENT }|. " -123,45

* Zahlen 2
WRITE: / |SCIENTIFIC:                   { num STYLE = SCIENTIFIC }|.                   " -1.2345E+02
WRITE: / |SCIENTIFIC_WITH_LEADING_ZERO: { num STYLE = SCIENTIFIC_WITH_LEADING_ZERO }|. " -0.12345E+03
WRITE: / |SCALE_PRESERVING_SCIENTIFIC:  { num STYLE = SCALE_PRESERVING_SCIENTIFIC }|.  " -1.2345E+0002
WRITE: / |ENGINEERING:                  { num STYLE = ENGINEERING }|.                  " -123.45E+00

* Datumsformat
WRITE: / |RAW:         { sy-datum DATE = RAW }|.         " 20160705
WRITE: / |ISO:         { sy-datum DATE = ISO }|.         " 2016-07-05
WRITE: / |USER:        { sy-datum DATE = USER }|.        " 05.07.2016
WRITE: / |ENVIRONMENT: { sy-datum DATE = ENVIRONMENT }|. " 05.07.2016

* Uhrzeitformat
WRITE: / |RAW:         { sy-uzeit TIME = RAW }|.         " 102336
WRITE: / |ISO:         { sy-uzeit TIME = ISO }|.         " 10:23:36
WRITE: / |USER:        { sy-uzeit TIME = USER }|.        " 10:23:36
WRITE: / |ENVIRONMENT: { sy-uzeit TIME = ENVIRONMENT }|. " 10:23:36

* Timestampformat
DATA: lv_tsl TYPE timestampl.
* Zeitstempel lang
GET TIME STAMP FIELD lv_tsl.
WRITE: / |SPACE:       { lv_tsl TIMESTAMP = SPACE }|.       " 2016-07-05 08:23:36.0908600
WRITE: / |ISO:         { lv_tsl TIMESTAMP = ISO }|.         " 2016-07-05T08:23:36,0908600
WRITE: / |USER:        { lv_tsl TIMESTAMP = USER }|.        " 05.07.2016 08:23:36,0908600
WRITE: / |ENVIRONMENT: { lv_tsl TIMESTAMP = ENVIRONMENT }|. " 05.07.2016 08:23:36,0908600

* ABAP Serialization XML (axXML)
WRITE: / |XML: { lv_tsl XSD = YES }|. " 20160705082336.09086