« Prev | Next » Time and Date Operations Aldec provides the following VHDL functions for performing time and date operations: get_clocktime() get_asctime() get_local_timezone() 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. time_value_sec Stores the time written in the UNIX/POSIX format. The value in this field expresses the number of seconds that have elapsed since the 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970. The field is of the time_value_t integer type that can take values of any positive integer, 0, or the special -1 value used in the epoch constant. second, minute, hour, day, day_of_week, day_of_year, month, and year These fields store the time and date specified with the common time units such as: seconds, hours, months, years, etc. The hour field uses the 24-hour clock convention. The range of the week field is 1 to 7 and the consecutive days of a week are assigned to its values starting from Sunday which is associated with the value 1 (1=Sunday, 2=Monday, 3=Tuesday, etc.). time_value_usec Stores the value of microseconds specified manually or with the get_clocktime() function. If the function reads the clock of the system providing microsecond timing accuracy, the field stores the number of microseconds that elapsed. On the other systems, 0 is written to this field. local_timezone_offset, daylight_saving_time The first field specifies the time zone expressed in seconds compensating the difference between the UTC and the local time; the latter one denotes whether the daylight saving time (DST) is used. The values of the daylight_saving_time field are as follows: -1 - no information is provided, 0 - DST is disabled, 1 - DST is enabled. 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. Previous article Next article