Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed error that causes possible duplicated hash numbers sometimes

  • Loading branch information...
commit cd437737fda7f47cbbb27fab4ec86d0e7c0ff57d 1 parent eb02bed
Lastres authored beerriot committed
4 apps/wriaki/src/article.erl
View
@@ -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(
7 apps/wriaki/src/article_dtl_helper.erl
View
@@ -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]).
Please sign in to comment.
Something went wrong with that request. Please try again.