anchor.diff:      end.
   
   
  -%%--------------------------------------------------------------------
  -%% @doc
  -%% Convert unix epoch to iso8601 format.
  -%% @end
  -%%--------------------------------------------------------------------
  --spec epoch_to_iso8601(Epoch :: non_neg_integer()) -> binary().
  +-spec epoch_to_iso8601(seconds()) -> binary().
   epoch_to_iso8601(Epoch) ->
       iso8601:format({Epoch div 1000000, Epoch rem 1000000, 0}).
   
   
  -%%--------------------------------------------------------------------
  -%% @doc
  -%% Convert iso8601 format to unix epoch time.
  -%% @end
  -%%--------------------------------------------------------------------
  --spec iso8601_to_epoch(binary()) -> non_neg_integer().
  +-spec iso8601_to_epoch(binary()) -> seconds().
   iso8601_to_epoch(Iso8601) ->
       DateTime = datestamp_to_datetime(Iso8601),
       datetime_to_epoch(DateTime).
   
   
  -%%-------------------------------------------------------------------
  -%% @doc
  -%% Converts erlang datetime to unix epoch time.
  -%% @end
  -%%-------------------------------------------------------------------
  --spec datetime_to_epoch(calendar:datetime()) -> non_neg_integer().
  +-spec datetime_to_epoch(calendar:datetime()) -> seconds().
   datetime_to_epoch({{_, _, _}, {_, _, _}} = DateTime) ->
       calendar:datetime_to_gregorian_seconds(DateTime) - ?UNIX_EPOCH.
  +
  +
  +-spec epoch_to_datetime(seconds()) -> calendar:datetime().
  +epoch_to_datetime(TimestampSeconds) ->
  +    calendar:gregorian_seconds_to_datetime(TimestampSeconds + ?UNIX_EPOCH).
   
   
   %%%--------------------------------------------------------------------
  
positive.code: %% Synchronizes time with a remote server (procedure to get the timestamp should
  %% be given as RemoteTimestampFun). Calculates estimated bias between local and
  %% remote clock and caches it for some time, hence limiting number of remote
  %% API calls. The time is returned in seconds, and in most cases it has one
  %% second accuracy.
  %% Cache key is used to allow different caches for different remote servers.
  %% Any errors should be logged inside the RemoteTimestampFun fun and 'error'
  
negative.code: %% @equiv erlang:system_time(milli_seconds).
  %% @end
  %%--------------------------------------------------------------------
  -spec system_time_millis() -> millis().
  system_time_millis() ->
      erlang:system_time(milli_seconds).
  
  