Skip to content

Runs code formatter on NaiveDateTime #6889

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

Merged
merged 1 commit into from
Oct 11, 2017

Conversation

nirev
Copy link
Contributor

@nirev nirev commented Oct 11, 2017

Hopefully it is all good :)

raise ArgumentError,
"cannot calculate the difference between #{inspect(naive_datetime1)} and #{
inspect(naive_datetime2)
} because their calendars are not compatible and thus the result would be ambiguous"
Copy link
Contributor Author

@nirev nirev Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this break feels a little strange to me, but the only way I could come up to avoid it was to concatenate multiple strings. any comments?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do split the message into multiple strings and concatenate them with <>. It's what we do all over the codebase 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thank you for reviewing it!

minute: minute,
second: second,
microsecond: microsecond
}) do
Copy link
Contributor Author

@nirev nirev Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to change this to the following?

def to_string(naive_datetime) do
  %{calendar: calendar,
      year: year,
      month: month,
      day: day,
      hour: hour,
      minute: minute,
      second: second,
      microsecond: microsecond} = naive_datetime

  calendar.naive_datetime_to_string(year, month, day, hour, minute, second, microsecond)
end

If changed and a map/struct not matching this keys is passed to the function, it would change the expected error. I felt like keeping the keys there made more sense.

comments?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please keep the keys in order to leave the semantics intact. We can always revisit later if we want to do more "refactory" changes.

@nirev nirev force-pushed the format-naive-datetime branch from fcf2a39 to d41034d Compare October 11, 2017 13:35
@nirev nirev force-pushed the format-naive-datetime branch from d41034d to 30d2933 Compare October 11, 2017 13:37
@josevalim josevalim merged commit 77c8224 into elixir-lang:master Oct 11, 2017
@josevalim
Copy link
Member

❤️ 💚 💙 💛 💜

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

Successfully merging this pull request may close these issues.

3 participants