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

  • Home
  • SEARCH
  • 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 9183731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:52:35+00:00 2026-06-17T18:52:35+00:00

I was wondering what the best approach would be to validate a date is

  • 0

I was wondering what the best approach would be to validate a date is within the correct opening hours of a shop…

I am creating a website for a golf professional and am taking bookings for lessons on it. I have used fullCalendar for the calendar and integrated it with google calendar so it can be easily sync’d to the pro’s mobile easily etc.

As part of the calendar, when a customer clicks on a time slot I am provided with a date object by fullcalendar. I want to validate that this selected slot falls within the opening times of the shop for lessons to be taken etc.

The times will be retrieved from a db table at some point but I can have them returned in JSON onto the page if it works best – but thats not the purpose of this question…

The opening hours differ depending on the day of the week as well as the “season” [summer times -vs- winter times]

ie:
 Summer Times
    Monday = 10:00 - 21:00
    Tuesday = 10:00 - 21:00
    Wednesday = 10:00 - 21:00
    Thursday = 10:00 - 21:00
    Friday = 10:00 - 21:00
    Saturday = 08:00 - 18:00
    Sunday = 08:00 - 18:00

 Winter Times
    Monday = CLOSED
    Tuesday = 10:00 - 18:30
    Wednesday = 10:00 - 18:30
    Thursday = 12.00 – 20.30
    Friday = 12.00 – 20.30
    Saturday = 08:00 - 18:00
    Sunday = 08:00 - 18:00

What would the “best” way be to validate this?

would the best option be to simply do nested if/switch statements..

[sudo code]
if(summer}
{
    switch(date.getDay())
    {
    case 1:
          if(time > mondayOpeningTime && time < mondayCloseTime)
          {
            return true;
          }
          else
          {
            return false;
          }
      break;
    case 2:
      execute code block 2
      break;
    .....
    default:
      code to be executed if n is different from case 1 and 2
    }
}
else
{
    // Same as summer logic but for winter times etc..
} 

Or is there a better way of doing this?

Apologies for the long post/question but thanks in advance to anyone who spends the time reading and responding to it 🙂

Chris

  • 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-17T18:52:36+00:00Added an answer on June 17, 2026 at 6:52 pm

    You want 2 arrays: openingTimes and closingTimes. First dimension will be season, second dimension will be day of the week. Then it’s just:

    return ((time > openingTimes[season, dayOfWeek]) && (time < closingTimes[season, dayOfWeek]));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering what would be the best approach for creating tables in a
Was just wondering what the best approach is when creating a multi-lingual website that
I am wondering what would be the best approach to store, for let's say
I've discovered this jsFiddle and I'm now wondering what the best approach would be
I was wondering how one would best approach the task of deciding upon the
I was wondering what would be the best approach towards finding the index of
I was wondering what the best approach would be to the following problem. Say
I am wondering what the best approach would be to check whether or not
I am wondering what would be the best approach in a WPF (possibly MVVM)
I was wondering what the best approach would be for the following situation: I

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.