Time Functions
TwinCAT provides functions for time conversion, they are declared in TcTimeConversion.h, which is part of TwinCAT SDK.
Methods provided
Name | Description |
---|---|
TcDayOfWeek(WORD day, WORD month, WORD year) | Determines the day of the week. |
TcIsLeapYear | Determines whether the given year is a leap year. |
TcDaysInYear | Determines the number of days in a given year. |
TcDaysInMonth | Determines the number of days in a given month. |
TcSystemTimeToFileTime(const SYSTEMTIME* lpSystemTime, FILETIME *lpFileTime); | Converts the given system time into a file time. |
TcFileTimeToSystemTime(const FILETIME *lpFileTime, SYSTEMTIME* lpSystemTime); | Converts the given file time into a system time. |
TcSystemTimeToFileTime(const SYSTEMTIME* lpSystemTime, ULONGLONG& ul64FileTime); | Converts the given system time into a file time (ULONGLONG format). |
TcFileTimeToSystemTime(const ULONGLONG& ul64FileTime, SYSTEMTIME* lpSystemTime); | Converts the given file time (ULONGLONG format) into a system time. |
TcIsISO8601TimeFormat(PCCH sDT) | Checks whether a PCCH follows the time format ISO8601. |
TcDecodeDateTime(PCCH sDT) | Converts a ULONG as DateTime from the PCCH into ISO8601 format. |
TcDecodeDcTime(PCCH sDT) | Converts a LONGLONG as DcTime from the PCCH into ISO8601 format. |
TcDecodeFileTime(PCCH sFT) | Converts a LONGLONG as FileTime from the PCCH into ISO8601 format. |
TcEncodeDateTime(ULONG value, PCHAR p, UINT len) | Converts a string (p, len) into ISO8601 format on the basis of the ULONG value in DateTime format. Minimum length for p is 24 bytes. |
TcEncodeDcTime(LONGLONG value, PCHAR p, UINT len) | Converts a string (p, len) into ISO8601 format on the basis of the LONGLONG in DcTime format. Minimum length for p is 32 bytes. |
TcEncodeFileTime(LONGLONG value, PCHAR p, UINT len) | Converts a string (p, len) into ISO8601 format on the basis of the LONGLONG in FileTime format. Minimum length for p is 32 bytes. |
TcDcTimeToFileTime(LONGLONG dcTime) | Converts a LONGLONG as FileTime from the LONGLONG into DcTime. |
TcFileTimeToDcTime(LONGLONG fileTime); | Converts a LONGLONG as DcTime from the LONGLONG into FileTime. |
TcDcTimeToDateTime(LONGLONG dcTime) | Converts a ULONG as DateTime from the LONGLONG into DcTime. |
TcDateTimeToDcTime(ULONG dateTime) | Converts a ULONG as DcTime from the LONGLONG into DateTime. |
TcFileTimeToDateTime(LONGLONG fileTime) | Converts a ULONG as DateTime from the LONGLONG into FileTime. |
TcDateTimeToFileTime(ULONG dateTime) | Converts a LONGLONG as FileTime from the ULONG into DateTime. |
- Further information on different time sources is described here:
https://infosys.beckhoff.com/content/1031/ethercatsystem/2469114379.html