Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8104573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:53:19+00:00 2026-06-05T23:53:19+00:00

Specifically: I have a Schedule model where a person cans schedule one event per

  • 0

Specifically: I have a Schedule model where a person cans schedule one event per day at the same time every day. Like this:

class Schedule

  include Mongoid::Document
  include Mongoid::Timestamps 

  field :hour,      :type => Integer, :default => 8
  field :ampm,      :type => String,  :default => "am"
  field :time_zone, :type => String,  :default => "Eastern Time (US & Canada)"

  field :monday,    :type => Boolean, :default => true
  field :wednesday, :type => Boolean, :default => true
  field :friday,    :type => Boolean, :default => true

  field :tuesday,   :type => Boolean, :default => false
  field :thursday,  :type => Boolean, :default => false
  field :saturday,  :type => Boolean, :default => false
  field :sunday,    :type => Boolean, :default => false

  embedded_in :user

end

I have a rake task that is run hourly and I just want to query for all schedules that require and event “now”. So for example if it is noon UTC on a Monday, then a schedule with :timezone => EST and :hour => 7 should be in the results as should a schedule with :timezone => PST and :hour => 4. This of course is a lot more tricky when it is, say, 1am UTC Tuesday because that is Monday in both PST/EST.

I thought about just normalizing the hour so everyone was on utc but this would create a mess for me with the days because someone might schedule something for 11pm wed which is actually thurs utc, so “normalization” would become a total pita where the days users select in their scheduler form wouldn’t correspond with the days we stored in the db.

I’m using mongoid in case anyone has a mongoid specific solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:53:20+00:00Added an answer on June 5, 2026 at 11:53 pm

    If it’s not an option to save the dates in UTC, you’ll have to query each time zone separately. Something like:

    wdays = [:sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday]
    now = Time.now
    TimeZone.all.each { |time_zone|
      remote_time = now.in_time_zone(time_zone)
      schedules = Schedules.where(
        :time_zone => time_zone.name,
        :hour => remote_time.strftime("%-l").to_i,
        :ampm => remote_time.strftime("%P"),
        wdays[remote_time.wday] => true,
      )
      # process schedules
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

They're both resizable arrays, and std::basic_string doesn't have any specifically character-related functions like upper().
I have a custom list in SharePoint (specifically, MOSS 2007.) One field is a
We have a very high performance multitasking, near real-time C# application. This performance was
Specifically I have code that simplifies to this: from datetime import datetime date_string =
i would like to have an array of objects in excel that call one
I have input bytes from ffmpeg. I'd like to send this output to several
Does anyone know how to do this? Specifically I have two arrays and some
Or at least the part of it, that makes sense. More specifically I have
Are there any compression algorithms -- lossy or lossless -- that have been specifically
Anyone have experience playing audio (right now specifically mp3s) with python using a any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.