Render conditional using Timex

I want to render something only if it’s older than 5 business days. I have the logic down to older than 5 days using Timex, how would I make sure it only counts business days?

 def render_5_days_ago(data) do
    if Timex.diff(Timex.now(), data.submitted_at, :days) >= 4, do: x, else: y
  end

Define a “business day” – pretty sure it’s going to be location- and calendar- dependent :grinning:

1 Like

Apologies. Based on the New York time-zone :slight_smile:

There is no built in function in Timex for that. You will have to create your own function that does that calculation :slight_smile: