#elixir-lang

/

      • mitchellhenke has quit
      • leafybasil
        Got a super noobish question, how do I generate a timestamp in elixir?
      • Or even access any concept of time...
      • jmcnutt has quit
      • juancate_ joined the channel
      • Havvy
        leafybasil: Erlang's standard library has time stuff.
      • leafybasil
        Havvy: ahh, didn't even think about that. Is it idiomatic to use erlang stdlib a lot?
      • jeffweiss joined the channel
      • Havvy
        Yes.
      • chrismccord
        leafybasil: Yep. If you need something higher level you can check out https://github.com/bitwalker/timex
      • Havvy
        You can also use other Erlang libraries.
      • chrismccord
        leafybasil: But erlang has plenty of time functions as wel
      • leafybasil
        chrismccord: i'm looking at that right now, but really all I need is time in millis.
      • chrismccord
        ~~ :os.timestamp()
      • beamie
        {1420, 70972, 454598}
      • leafybasil
        chrismccord: which prompted the question
      • Havvy
        Just note that it's `:module.fn()` instead of `Module.fn()`
      • leafybasil
        (Also, probably obviously, I'm learning elixir)
      • I also don't see 'os' listed in erland stdlib
      • Havvy
      • Welcome to Elixir. It's a wonderful language.
      • leafybasil
        Ahh, I was somehow under /doc/apps/stdlib, thanks Havvy
      • chrisconstantin has quit
      • Havvy / chrismccord, thanks, ended up with :calendar.time_to_seconds(:os.timestamp), and now I know!
      • true_droid
      • ah, it expects {hour, minute, second}
      • leafybasil: :os.timestamp is incompatible with time_to_seconds
      • tdeficit joined the channel
      • if'd better do {mega,secs,milli} = :os.timestamp; mega*1000000 + secs
      • seubert_ joined the channel
      • leafybasil
        true_droid: you say that but it seems to generate a valid value...
      • true_droid: loading your gist
      • O_o are you experiencing time fluctuations? Do you happen to live near a neutron star?
      • true_droid
        time_to_seconds expects {hour(), minute(), second()}
      • leafybasil
        So the value is most likely invalid :(
      • true_droid
        :os.timestamp returns {MegaSecs, Secs, MicroSecs}
      • it's a different value
      • it's just a coincedence the shape is the same
      • leafybasil
        Yeah that make sense, sorry when you said incompatible I expected an error
      • true_droid: also saves me from importing calendar, so more win
      • seubert has quit
      • true_droid
        leafybasil: calendar is likely to be loaded anyway, you shouldn't worry about that
      • leafybasil
        true_droid: ahh, yet more i didn't know
      • jay has quit
      • chrisconstantin joined the channel
      • chrisconstantin has quit
      • chrisconstantin joined the channel
      • pmonson has quit
      • swartulv joined the channel
      • JuanMiguel has quit
      • nox_
        chrismccord: Could you summarise what timex does better?
      • Oh, formatting.
      • chrismccord
        nox_: I don't have too much experience with the erl modules, so I can't speak to better. Timex's goal is to become part of the std lib
      • nox_
        chrismccord: Well, The calendar module has no formatting.
      • At all.
      • chrismccord
        ah. Well that's one nicety then
      • I usually tell folks to check the erlang modules, then reach for timex if they need more
      • nox_
        Yes.
      • No tz either.
      • tristan_1
        we have a number of third party time libs for formatting
      • Erlware!
      • nox_
        Should be in OTP imo.
      • But not in stdlib.
      • Out of curiosity, is there a reverse/2 in Elixir?
      • adamkittelson
        there's a reverse/2 in the Enum module
      • vhyza has quit
      • jepi has quit
      • richsoni joined the channel
      • tdeficit joined the channel
      • true_droid has quit
      • chrisconstantin has quit
      • leafybasil
        I have a question regarding HTTPotion if anyone has any experience, I can set headers, but the key becomes prefixed with HTTP_, so how can I set cookies given the prefix happens?
      • eka joined the channel
      • bcinman has quit