clockTimeToLinsec (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Firmware version:

1.00 / 1.00.00


This function can be used to convert a time in year, month, day, hour, minute, and second format to number of seconds since 1980-1-1 00:00:00.

 

Input:

year : INT (-1, 1980 .. 2048) (Default -1)

The current year.

 

month : SINT (-1, 1 .. 12) (Default -1)

The current month.

 

day : SINT (-1, 1 .. 31) (Default -1)

The current date.

 

hour: SINT (-1 .. 23) (Default -1)

The current hour.

 

minute : SINT (-1 .. 59) (Default -1)

The current minute.

 

second : SINT (-1 .. 59) (Default -1)

The current second.

 

Returns: DINT

The specified time in seconds since 1980-1-1 00:00:00.

 

Declaration:

FUNCTION clockTimeToLinsec DINT;
VAR_INPUT
   Year   : INT  := -1;  // 1980..2048 
   Month  : SINT := -1;  // 01..12     
   Day    : SINT := -1;  // 01..31     
   Hour   : SINT := -1;  // 00..23     
   Minute : SINT := -1;  // 00..59     
   Second : SINT := -1;  // 00..59     
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
 
VAR
   a : DINT;
END_VAR;
 
BEGIN
   ...
   // Convert 2001-12-24 12:00:30 to number of seconds since 1980-1-1 00:00:00
   a := clockTimeToLinsec(year := 2001, month := 12, day := 24, hour:=12, minute:=0, second:=30);
   ...
END;
 
END_PROGRAM;