Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 23 lines (19 sloc) 0.796 kB
6ab3d15 @trung amf3 read complete
authored
1 -module(utils).
2 -author("trung@mdkt.org").
3 -compile(export_all).
4
5 milliseconds_to_date(Milliseconds) ->
41a2260 @trung test cases for read/write amf0
authored
6 BaseDate = calendar:datetime_to_gregorian_seconds({{1970,1,1},{8,0,0}}),
7 Seconds = BaseDate + (trunc(Milliseconds) div 1000),
6ab3d15 @trung amf3 read complete
authored
8 calendar:gregorian_seconds_to_datetime(Seconds).
41a2260 @trung test cases for read/write amf0
authored
9
10 %% Convert date to milliseconds since 0:0:0 1/1/1970
11 %% Date = date() {{Date}, {Time}}
12 date_to_milliseconds(Date) ->
13 BaseDate = calendar:datetime_to_gregorian_seconds({{1970,1,1},{8,0,0}}),
14 Seconds = calendar:datetime_to_gregorian_seconds(Date),
15 DiffSeconds = Seconds - BaseDate,
16 DiffSeconds * 1000.
0b13b0c @trung created helper to generate record_utils dynamically for records
authored
17
18 %% Convert String to term, Str must be term-like string
19 to_term(Str) ->
20 {ok, Tokens, _} = erl_scan:string(Str),
21 {ok, Term} = erl_parse:parse_term(Tokens ++ [{dot,1}]),
22 Term.
Something went wrong with that request. Please try again.