tompave / fun_with_flags

Feature Flags/Toggles for Elixir
https://hexdocs.pm/fun_with_flags/FunWithFlags.html
MIT License
1.08k stars 79 forks source link

Feature time based flags #185

Open mohammedzeglam-pg opened 2 days ago

mohammedzeglam-pg commented 2 days ago

Flags enabled and disabled based on time or timezone

probably-not commented 14 hours ago

This can be done with just a simple Group implementation. Something along the lines of:

defmodule UserWithATimeZone do
  defstruct details: %{}, time_zone: "Etc/UTC"
end

defimpl FunWithFlags.Group, for: UserWithATimeZone do
  def in?(%UserWithATimeZone{time_zone: time_zone}, time_zone), do: true
  def in?(_user, _time_zone), do: false
end