Skip to content

Commit

Permalink
fixed error that causes possible duplicated hash numbers sometimes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lastres authored and beerriot committed Jun 22, 2012
1 parent eb02bed commit cd43773
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/wriaki/src/article.erl
Expand Up @@ -141,8 +141,8 @@ get_timestamp(Article) ->
wobj:get_json_field(Article, ?F_TS).

update_version(Article) ->
{MS, S, _US} = now(),
TS = 1000000*MS+S,
{MS, S, US} = now(),
TS = 1000000000000*MS + 1000000*S + US,
wobj:set_json_field(
wobj:set_json_field(Article, ?F_TS, TS),
?F_VERSION, list_to_binary(
Expand Down
7 changes: 4 additions & 3 deletions apps/wriaki/src/article_dtl_helper.erl
Expand Up @@ -114,9 +114,10 @@ history() ->

%% @spec format_time(datetime()) -> iolist()
%% @doc format a history timestamp for display in HTML
format_time(EpochSecs) ->
Secs = EpochSecs rem 1000000,
MegaSecs = (EpochSecs-Secs) div 1000000,
format_time(TS) ->
MicroSecs = TS rem 1000000,
Secs = ((TS-MicroSecs) div 1000000) rem 1000000,
MegaSecs = (TS-Secs*1000000-MicroSecs) div 1000000000000,
{{Y,M,D},{H,I,S}} = calendar:now_to_universal_time({MegaSecs, Secs, 0}),
io_lib:format("~4..0b.~2..0b.~2..0b ~2..0b:~2..0b:~2..0b",
[Y,M,D,H,I,S]).
Expand Down

0 comments on commit cd43773

Please sign in to comment.