Skip to content

Time zone not passed to worker threads #341

@KaneMorgan

Description

@KaneMorgan

I've noticed something that was surprising to me. It seems as though setting the Timezone for the scheduler is not persisted to the child threads.

This should illustrate the issue

require 'rufus-scheduler'
require 'active_support/core_ext/time/zones'

Time.zone = 'Asia/Shanghai'
Rufus::Scheduler.new.in "2s" do
  puts "Timezone is: #{Time.zone} EtOrbi zone: #{EtOrbi.zone}"
end

The output of this is Timezone is: EtOrbi zone: Europe - Belfast

In the parent the timezone is Asia/Shanghai

irb(main):009:0> EtOrbi.zone
=> #<TZInfo::DataTimezone: Asia/Shanghai>

I'd expected for the thread to have the same timezone as the scheduler.

For now I'm explicitly setting the timezone in the do block, but just wondered whether the above was intended

We are on rufus-scheduler 3.8.2

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions