UTC

2020-09-07
2020-09-07
  • Reinier Geers

    Reinier Geers - 2020-09-07

    with SysTimeRtcConvertDateToUtc and SysTimeRtcConvertUtcToDate i can convert a date to dayofyear ( wYday ). but how can i change wYday back to date ?

     
  • i-campbell

    i-campbell - 2020-09-07

    I couldn't find an inbuilt function, but..

    PROGRAM PLC_PRG
    VAR
        lastNewYearsEve : SysTimeRtc.SYSTIMEDATE := (wYear := 2019, wMonth := 12, wDay := 31);
        wYear: WORD := 2020;
        wYday: WORD := 1;
        dDate: Date;
        dwLastNewYearsEve: DWORD;
    END_VAR
    
    lastNewYearsEve.wYear := wYear - 1;
    wYday := MAX(MIN(366,wYday),1);
    SysTimeRtc.SysTimeRtcConvertDateToUtc(lastNewYearsEve,dwLastNewYearsEve);
    dDate := TO_DATE(dwLastNewYearsEve + wYday * 60*60*24);
    
     

Log in to post a comment.