Open vamsii777 opened 2 days ago
This seems like duplicated configuration as you can already achieve this using:
let calendar = Calendar.current
calendar.timeZone = TimeZone(identifier: "America/New_York")!
app.queues.schedule(Cleanup())
.using(calendar)
...
This seems like duplicated configuration as you can already achieve this using:
let calendar = Calendar.current calendar.timeZone = TimeZone(identifier: "America/New_York")! app.queues.schedule(Cleanup()) .using(calendar) ...
Thank you for the feedback @grahamburgsma! While .using(calendar)
works, .in(timezone:)
simplifies the API and improves developer experience by directly supporting timezone specification in the scheduling step.
API Consistency
The proposed .in(timezone:)
modifier follows existing builder pattern and provides a more intuitive API that aligns with how developers think about scheduling across timezones.
app.queues.schedule(Cleanup())
.in(timezone: "America/New_York")
.daily()
.at("9:00am")
Developer Experience
While .using(calendar)
works, it requires:
This approach avoids the need to configure a Calendar, making the code cleaner and more intuitive. Thanks again for sharing your thoughts!
There are two main ways to set the timezone for scheduling jobs:
in
method// Using timezone abbreviation app.queues.schedule(Cleanup()).in(timezone: "EST").daily().(.midnight)