clockLinsecToTime (Functionblock)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Firmware version:

1.00 / 1.00.00


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

 

Input:

linsec : DINT

Number of seconds since 1980-1-1 00:00:00

 

Output:

year : INT (1980 .. 2048)

The current year.

 

month : SINT (1 .. 12)

The current month.

 

day : SINT (1 .. 31)

The current date.

 

hour: SINT (0 .. 23)

The current hour.

 

minute : SINT (0 .. 59)

The current minute.

 

second : SINT (0 .. 59)

The current second.

 

dayofweek : SINT (1 .. 7)

The current day of week, 1 = Monday, 2 = Tuesday... 7 = Sunday.

 

Declaration:

FUNCTION_BLOCK clockLinsecToTime;
VAR_INPUT
   Linsec    : DINT;   // Seconds since 1980-1-1 00:00:00
END_VAR;
VAR_OUTPUT
   Year      : INT;    // 1980..2048 
   Month     : SINT;   // 01..12     
   Day       : SINT;   // 01..31     
   Hour      : SINT;   // 00..23     
   Minute    : SINT;   // 00..59     
   Second    : SINT;   // 00..59     
   DayOfWeek : SINT;   // 1..7     
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
VAR
   clock : clockLinsecToTime; // Declare an instance of the clockLinsecToTime functionblock
END_VAR
 
PROGRAM test;
 
BEGIN
   ...
   clock(Linsec:=30);
   // clock.year, clock.month, clock.day, clock.hour, clock.minute, clock.second is now 1980-1-1 00:00:30
   ...
END;
 
END_PROGRAM;