How to access oban timezone in meta?

I’m using Oban.Pro.Worker and would like to access the timezone in the new/2 method; currently I see cron, cron_expr, and cron_name but not the timezone passed along:

config :example, Oban,
  plugins: [
    Oban.Pro.Plugins.DynamicLifeline,
    {
      Oban.Pro.Plugins.DynamicCron,
      sync_mode: :automatic,
      crontab: [
        {"* * * * 1-5", Example.Worker, timezone: "America/New_York"}
      ]
    }
  ]
  opts: [
    stages: [
      {Oban.Pro.Stages.Standard, []},
      {Oban.Pro.Stages.Structured,
       %Oban.Pro.Stages.Structured{worker: Example.Worker}},
      {Oban.Pro.Stages.Hooks, %Oban.Pro.Stages.Hooks{modules: []}}
    ],
    worker: "Example.Worker",
    meta: %{
      cron: true,
      cron_expr: "* * * * 1-5",
      cron_name: "Example.Worker"
    }
  ]

Any advice besides passing the timezone again as an argument?

Thanks!

That is probably the most straightfoward way to do it, but there are a few other options.

One, use the cron_name to look up the timezone from the DynamicCron entry. This is guaranteed to be accurate:

def process(%Job{args: args, meta: meta}) do
  %{opts:%{"timezone" => timezone}} = Repo.get_by(Oban.Pro.Cron, name: meta["cron_name"])
  
  ...
end

There should arguably be a DynamicCron.get to make that easier.

The second option is to read it from the static config, which wouldn’t be accurate if you’re using the “dynamic” part of DynamicCron.