Time and Date Operations

Aldec provides the following VHDL functions for performing time and date operations:

The functions are located in the aldec_tools package in the pre-installed aldec library. To use them, insert the following library and use clauses:

library aldec;
use aldec.aldec_tools.all;

clocktime_rec Record

The functions operate on values written in the UNIX/POSIX format. The time presented in this format and converted to common units such as seconds, hours, months, years, etc. is stored in the fields of the clocktime_rec record whose declaration is located in the aldec_tools package.

epoch Constant

The epoch constant is a record of the clocktime_rec type whose time_value_sec field is equal -1 and storing the Unix epoch, that is, 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970 in its remaining fields. The get_asctime() function operates on the current system time if that constant is passed as a parameter.

get_clocktime() Function

The function returns the record of the clocktime_rec type representing the time specified with the t parameter. The parameter value is interpreted as the number of seconds that have elapsed since the 00:00:00 UTC, Thursday, 1 January 1970. If the -1 value is passed or the t parameter is omitted, the function returns the record representing the system time and date. If the localize parameter is true, the local time specified in the system settings is in the use; otherwise, the UTC time is applied.

impure function get_clocktime(t : in time_value_t := -1; localize : in boolean := true) return clocktime_rec;

Returned value

A record of the clocktime_rec type containing the time specified with the t parameter or the current system time.

get_asctime() Function

The function returns the string representing the time and date stored in the clocktime_rec record specified as the tr parameter. If the epoch constant is passed or the parameter is omitted, the function returns the time and date indicated by the system clock.

impure function get_asctime(tr : in clocktime_rec := epoch) return string;

Returned value

A string representing a time and date.

get_local_timezone() Function

The function returns the time zone kept by the system clock.

impure function get_local_timezone( tr : in clocktime_rec := epoch ) return string;

Returned value

A string representing a time zone.



Printed version of site: www.aldec.com/en/support/resources/documentation/articles/1819