Convert the a time to a time number, the number of hours, minutes and seconds 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/2 encode_time/3 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, 2, 2, TimeNum). | succeeds and the calculated time number is unified with the
variable TimeNum TimeNum = 122 |
| encode_time(13, 1, 5, TimeNum). | succeeds and the calculated time number is unified with the
variable TimeNum TimeNum = 46865 |
| encode_time(13, 0, 10, 4567). | fails because the calculated value, which is 46810, is not equal to the value 4567 |
| Exceptions | |
| The Hour, Min and/or Sec parameter is not an integer | a type_error(evaluable, Value) exception is thrown, Value is unified with the incorrect parameter |
| The TimeNumber parameter is not an integer nor a variable | a type_error(evaluable, Value) exception is thrown, Value is unified with the incorrect parameter |