Permalink
Browse files

fixed error that causes possible duplicated hash numbers sometimes

  • Loading branch information...
1 parent eb02bed commit cd437737fda7f47cbbb27fab4ec86d0e7c0ff57d Lastres committed with Bryan Fink Jun 22, 2012
Showing with 6 additions and 5 deletions.
  1. +2 −2 apps/wriaki/src/article.erl
  2. +4 −3 apps/wriaki/src/article_dtl_helper.erl
View
4 apps/wriaki/src/article.erl
@@ -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(
View
7 apps/wriaki/src/article_dtl_helper.erl
@@ -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]).

0 comments on commit cd43773

Please sign in to comment.