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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:15:21+00:00 2026-05-17T19:15:21+00:00

The problem: I am in process of implementing a scheduler for my advisor in

  • 0

The problem:
I am in process of implementing a scheduler for my advisor in school. The scheduler supposes to setup a 15 minutes interval time slot from 8:00 AM to 5:00 PM, Monday to Friday. In addition, the advisor will have to specify the start and end dates of the scheduler. The scheduler will also feature an option to specify if the 15 minutes time slot is not open. Meaning my advisor will be able to mark specific time slot as NOT AVAILABLE.

What I have so far:
I have created a simple class:

public class TimeSlot  
    {
        public DateTime dateTime
        {
            get;
            set;
        }

        public bool isAvailable
        {
            get;
            set;
        }

        TimeSlot(DateTime dt, bool Avalible)
        {
            dateTime = dt;
            isAvailable = Avalible;
        } 
    }

The class basically represents an object for one time slot in the scheduler. I also have a list of time slots that keeps a list of the valid time slots:

List<TimeSlot> TSList = new List<TimeSlot>();

Note that a valid time slot means the following:

  1. Date is within: Monday to Friday.
  2. Time is within: 8:00 AM to 5:00 PM
  3. Time slots are within: 15 minutes interval.

In addition, I have a method that fill in the TSList as the following:

 private void button_Next_Click(object sender, RoutedEventArgs e)
    {
        /* Getting the values of fromDate and toDate from the GUI controls*/
        DateTime fromDate = datePicker1.SelectedDate.Value;
        DateTime toDate = datePicker2.SelectedDate.Value;

        while (fromDate <= toDate)
        {
            /*This ensures that we only deal with days Monday to Friday*/
            if (fromDate.DayOfWeek.ToString() != "Saturday" && fromDate.DayOfWeek.ToString() != "Sunday")
            {
                /*PROBLEM HERE!!*/
            }

            /*Updating fromDate: Incrementing fromDate by 1 day*/
            fromDate = fromDate.AddDays(1);
        }

    }

Notes that I was only able to satisfy the first condition in my valid time slot conditions. Thus, I was only able to restrict the dates to be within Monday to Friday range.

The questions:
I am trying to achieve the missing two valid conditions for a time slot:

  1. How to restrict the times to be only 8:00am to 5:00 pm?
  2. How to make time slots separated by 15 minutes interval?
  • 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-17T19:15:21+00:00Added an answer on May 17, 2026 at 7:15 pm

    First, please use DayOfWeek.Saturday and DayOfWeek.Sunday for the comparision, converting to a string is not necessary…

    Then just use a simple loop like

    DateTime startSlot = fromDate.Date.AddHours(8); // Starts at 8:00AM
    while (startSlot.Hour < 17) {
      // Construct time slot class
      startSlot = startSlot.AddMinutes(15);
    }
    

    This gives you startSlot values starting at 8:00am at every date ranging to 5pm (i.e. the last one is 4:45pm).

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

Sidebar

Related Questions

Everyone managing open-source-software runs into the problem, that with the time the process of
Kind of a special case problem: I start a process with System.Diagnostics.Process.Start(..) The process
I am in the process of setting up CruiseControl.NET. The problem I am having
i have little problem with boost::asio library. My app receive and process data asynchronously,
Problem: I have an address field from an Access database which has been converted
Problem: Given a list of strings, find the substring which, if subtracted from the
I am solving this problem. I am implementing cycling mapping, I have 4 processors,
Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem (simplified to make things clearer): 1. there is one statically-linked static.lib that has
Problem: Ajax suggest-search on [ n ] ingredients in recipes. That is: match recipes

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.