欢迎光临散文网 会员登陆 & 注册

博图TIA系统时间转unix时间戳

2021-06-23 18:13 作者:H0lyzer  | 我要投稿


接口定义

//Function: Converttoutime-converts DIL TO Unix Time

//Calculate the Unix time equlvalent OR the DIL time Input parameter

//Unix time 1s aimply the number of seconds since 1970-01-01-00: 00

//Rev1310n:04-22-2015

//n1t1a113e

#SecsPerDay :=24*60*60;

//Number of seconds for year component

#YearSecs := (#Time.YEAR - 1970) * 365 * #SecsPerDay;

//Number of leap year days (excluding year 2000)

#LeapDays := TRUNC_USINT(#Time.YEAR - 1972) / 4;

#LeapYear := ((#Time.YEAR - 1972) MOD 4 = 0) AND (#Time.YEAR <> 2000);

//Number of seconds for leap year component excluding January, February of leap year19 OIE (Leapyear AND #Time. MONTH <3) THEN

IF (#LeapYear AND #Time.MONTH<3) THEN

    #LeapSecs := (#LeapDays - 1) * #SecsPerDay;

ELSE

    #LeapSecs := #LeapDays * #SecsPerDay;

END_IF;

  //Number of seconds for month component

CASE #Time.MONTH OF

    1:

        #MonthSecs := 0;

        ;

    2:

        #MonthSecs := 31 * #SecsPerDay;

        ;

    3:

        #MonthSecs := (31 + 28) * + #SecsPerDay;

        ;

    4:

        #MonthSecs := (31 + 28 + 31) * #SecsPerDay;

        ;

    5:

        #MonthSecs := (31 + 28 + 31 + 30) * #SecsPerDay;

        ;

    6:

        #MonthSecs := (31 + 28 + 31 + 30 + 31) * #SecsPerDay;

        ;

    7:

        #MonthSecs := (31 + 28 + 31 + 30 + 31 + 30) * #SecsPerDay;

        ;

    8:

        #MonthSecs := (31 + 28 + 31 + 30 + 31 + 30 + 31) * #SecsPerDay;

        ;

    9:

        #MonthSecs := (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31) * #SecsPerDay;

        ;

    10:

        #MonthSecs := (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30) * #SecsPerDay;

        ;

    11:

        #MonthSecs := (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31) * #SecsPerDay;

        ;

    12:

        #MonthSecs := (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30) * #SecsPerDay;

END_CASE;

   //Number of seconds for day component

#DaySecs := #Time.DAY * #SecsPerDay;

   //Number of seconds for hour component

#HourSecs:=USINT_TO_UDINT(#Time.HOUR)*60* 60;

   //Number of seconds for minute component

#MinSecs := USINT_TO_UDINT(#Time.MINUTE) * 60;

   //Sum individual components

#UnixTime := #YearSecs + #LeapSecs + #MonthSecs + #DaySecs + #HourSecs + #MinSecs + #Time.SECOND;


博图TIA系统时间转unix时间戳的评论 (共 条)

分享到微博请遵守国家法律