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

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

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 38 39 401x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 1x 1x  
import {IStatement} from "./_statement";
import {seq, alt, per, ver, AlsoIn} from "../combi";
import {Target, Source} from "../expressions";
import {IStatementRunnable} from "../statement_runnable";
import {Release} 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 daylightSource = seq("DAYLIGHT SAVING TIME", Source);
    const daylightTarget = seq("DAYLIGHT SAVING TIME", Target);
    const zone = seq("TIME ZONE", Source);
 
    const time = seq("TIME STAMP",
                     Source,
                     per(zone, into, daylightTarget));
 
    const dat = seq("DATE", Source);
    const tim = seq("TIME", Source);
 
    const stamp = seq("INTO TIME STAMP", Target);
    const intoutc = ver(Release.v754, seq("INTO UTCLONG", Target), {also: AlsoIn.OpenABAP});
    const invert = seq("INTO INVERTED-DATE", Target);
 
    const date = seq(per(dat, tim),
                     per(daylightSource, stamp, zone, invert, intoutc));
 
    const inv = seq("INVERTED-DATE", Source, "INTO DATE", Target);
 
    const utclong = ver(Release.v754, seq("UTCLONG", Source, per(zone, into, daylightTarget)), {also: AlsoIn.OpenABAP});
 
    return seq("CONVERT", alt(time, date, inv, utclong));
  }
 
}