encode_time(+Hour, ?TimeNumber)

Convert the a time to a time number, only the number of hours since the start of a day can be specified. A time number is an integer that uniquely identifies a second in a day of 24 hours, i.e. it is the number of elapsed seconds since 0 : 0 : 0 (hour : min : seconds). Because time numbers are integers they can be used in arithmetic expressions.

This predicate is located in the file 'datetime.txt', use ensure_loaded/1 to include this file.

see also: age/7 day_number/4 day_of_week/2 datetime module decode_date/4 decode_datetime/7 decode_time/4 encode_date/4 encode_datetime/7 encode_time/3 encode_time/4 ensure_loaded/1 first_week/2 leap_year/1 length_month/3 monday_of_week/3 monday_of_week/5 next_week/4 num_weeks_in_year/2 prev_week/4 reverse_day_number/4 start_of_week/3

Example
encode_time(0, TimeNum). succeeds and the calculated time number is unified with the variable TimeNum
TimeNum = 0
encode_time(13, TimeNum). succeeds and the calculated time number is unified with the variable TimeNum
TimeNum = 46800
encode_time(13, 4567). fails because the calculated value, which is 46800, is not equal to the value 4567

 

Exceptions  
The Hour parameter is not an integer a type_error(evaluable, Value) exception is thrown, Value is unified with the incorrect parameter
A TimeNumber parameter is not an integer nor a variable a type_error(evaluable, Value) exception is thrown, Value is unified with the incorrect parameter

 

 

info@trinc-prolog.com