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 1075589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:17:41+00:00 2026-05-16T21:17:41+00:00

Suppose I have a particular UTC time T . I would like a method

  • 0

Suppose I have a particular UTC time T. I would like a method that returns true if it is possible that at least one spot somewhere else on Earth has the same local date as T right now.

def still_same_date?(t)
  # true
  #   if it is the same day at some other place on Earth
  # false
  #   otherwise
end

For example, let’s say T is today at 12:01 AM in my local time. Then clearly it’s true, because anyplace east of me will also have today’s date (it is later in the day at those spots).

But if T is yesterday at 4:00 PM in my local time, it is no longer obviously true that there is another place on Earth that still has that date.

And if T is January 1, 2000 at 6:58 PM in my local time, it is obviously false that there is another place on Earth with the same date.

How can I write still_same_date? so that it returns what I want?

  • 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-05-16T21:17:41+00:00Added an answer on May 16, 2026 at 9:17 pm

    Okay, to clarify this, you actually have two pieces of information:

    • A UTC instant
    • A date

    You want to see if at the given UTC instant, there are any time zones such that the date would be the given one. Note that your talk of “today” in the question doesn’t give a unique value for the date (due to different time zones – my “today” may not be the same as yours), which is why I’ve explicitly couched it in terms of a function with two parameters.

    Basically, you need to iterate. Pseudocode:

    for each time zone tz
      localTime = tz.GetLocalTime(utc)
      if (localTime.GetDate() == targetDate)
        return true
    
    return false
    

    Now you can definitely optimize this by finding the largest and smallest time zone offsets which would give you a “true” result, and applying boundaries. I can’t remember offhand what the largest and smallest offsets ever are, but I would safely guess that if you would need more than +15 or less than -15, you can return false immediately.

    You can likewise cut down on the time zones you test, to only use those which are known to be at an extreme at some point in history.

    Unless this is performance-critical though, I’d write the simple code and leave a TODO for optimization 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.