All files / src/abap/2_statements/statements convert.ts

100% Statements 38/38
100% Branches 1/1
100% Functions 1/1
100% Lines 38/38

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 381x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x
import {IStatement} from "./_statement";
import {seq, alt, per, ver} from "../combi";
import {Target, Source} from "../expressions";
import {IStatementRunnable} from "../statement_runnable";
import {Version} from "../../../version";
 
export class Convert implements IStatement {
 
  public getMatcher(): IStatementRunnable {
    const intoTime = seq("TIME", Target);
    const intoDate = seq("DATE", Target);
    const into = seq("INTO", per(intoTime, intoDate));
 
    const daylight = seq("DAYLIGHT SAVING TIME", Source);
    const zone = seq("TIME ZONE", Source);
 
    const time = seq("TIME STAMP",
                     Source,
                     per(zone, into, daylight));
 
    const dat = seq("DATE", Source);
    const tim = seq("TIME", Source);
 
    const stamp = seq("INTO TIME STAMP", Target);
    const intoutc = ver(Version.v754, seq("INTO UTCLONG", Target));
    const invert = seq("INTO INVERTED-DATE", Target);
 
    const date = seq(per(dat, tim),
                     per(daylight, stamp, zone, invert, intoutc));
 
    const inv = seq("INVERTED-DATE", Source, "INTO DATE", Target);
 
    const utclong = ver(Version.v754, seq("UTCLONG", Source, per(zone, into, daylight)));
 
    return seq("CONVERT", alt(time, date, inv, utclong));
  }
 
}