Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect conversion of Timex.now/1 to DateTime.utc_now/1 #66

Closed
kerryb opened this issue Aug 10, 2023 · 8 comments
Closed

Incorrect conversion of Timex.now/1 to DateTime.utc_now/1 #66

kerryb opened this issue Aug 10, 2023 · 8 comments

Comments

@kerryb
Copy link

kerryb commented Aug 10, 2023

Versions

  • Elixir: 1.15.2 (compiled with Erlang/OTP 26)
  • Styler: 0.8.3

Example Input

Timex.now("Europe/London")

Stacktrace / Current Behaviour

Styler converts Timex.now/1 to DateTime.utc_now/1, which expects a calendar or unit (not a timezone). This is the formatted code:

DateTime.utc_now("Europe/London")

I believe the correct conversion should be:

DateTime.now!("Europe/London")
@novaugust
Copy link
Contributor

:O thanks for the bug report! will have that fixed in a jiffy

@novaugust
Copy link
Contributor

fixed on main, will publish a release at the end of the workday =) thanks again for the report (and even moreso for telling me what it should be!)

@kerryb
Copy link
Author

kerryb commented Aug 10, 2023

Thanks for the quick fix!

@novaugust
Copy link
Contributor

released v0.8.4, hope this works better across the pond now :)

@sabiwara
Copy link

Hello! I noticed that this issue is still happening when using the pipe operator:

"Europe/London" |> Timex.now() |> dbg()
# becomes
"Europe/London" |> DateTime.utc_now() |> dbg()

The fix is happening on the node (apparent arity 0), but doesn't account for the effective arity of the call due to the pipe (arity 1).

@novaugust
Copy link
Contributor

ahh thank you sabiwara, and apologies for missing that. will get a fix up

@novaugust
Copy link
Contributor

published 0.9.5 with fix for the pipes problem. cheers

@sabiwara
Copy link

Thanks Matt for the fix and for the awesome project! Cheers 💜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants