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

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

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 341x 1x 1x 1x 1x 1x 1x 1x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 1x 1x
import {IStatement} from "./_statement";
import {seq, alt, per} from "../combi";
import {Target, Source} from "../expressions";
import {IStatementRunnable} from "../statement_runnable";
 
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 invert = seq("INTO INVERTED-DATE", Target);
 
    const date = seq(per(dat, tim),
                     per(daylight, stamp, zone, invert));
 
    const inv = seq("INVERTED-DATE", Source, "INTO DATE", Target);
 
    return seq("CONVERT", alt(time, date, inv));
  }
 
}