mnesia primary key creation

Ulf Wiger <>
Tue Jul 4 23:18:18 CEST 2006


Den 2006-07-04 21:31:26 skrev Roberto Saccon <>:

> I liked the cheap solution:
>
>   oid() -> {node(), erlang:now()}.
>
> but how can I turn erlang:now() into a String ?? (which probablly
> won't look very URL-friendly)
>
> I thouhgt of turing it into a list, then into a binary, then base64
> encoding it, but
>    list_to_binary(tuple_to_list(erlang:now()))
> does not work.

Well, for example:

1> {Node,{MS,S,US}} = {node(), erlang:now()}.
{,{1152,47770,297000}}
2>  
list_to_binary([atom_to_list(Node),"-",integer_to_list(MS),"-",integer_to_list(S),"-",integer_to_list(US)]).
<<110,111,110,111,100,101,64,110,111,104,111,115,116,45,49,49,53,50,45,52,55,55,55,48,45,50,57,55,48,...>>
3> binary_to_list(v(2)).
""

BR,
Ulf W

-- 
Ulf Wiger



More information about the erlang-questions mailing list