It doesn't make a whole lot of sense to me to have a function on DateTime that doesn't produce or accept a DateTime.
You can use :os.system_time() or :os.system_time(:second) if you want to get straight to the unix time. Allen Madsen http://www.allenmadsen.com On Wed, Aug 30, 2017 at 6:11 PM, Fernando Tapia Rico <[email protected]> wrote: > It's a little shortcut but it's the most used method in all the `utils.ex` > of my projects. > > @doc """ > Returns the current datetime in Unix time. > > It will return the integer with the given unit, according to > `System.convert_time_unit/3`. > """ > @spec now_unix(System.time_unit) :: integer > def now_unix(unit \\ :second) do > DateTime.utc_now() |> DateTime.to_unix(unit) > end > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/elixir-lang-core/37c433b7-ee09-4052-911c- > f58e2904be14%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/37c433b7-ee09-4052-911c-f58e2904be14%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAK-y3Cs8zQAU_71m9uG3rXBXAggeehd8_wfs1Dz4Q_Yy-3rw5A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
