locked
Implement a calendar that doesn't include Sundays RRS feed

  • Question

  • User1771308999 posted

    I'm working on creating a reservation system.

    I'm trying to display some form of calendar for the client side that can display the month and days in correspondent with that month. However, I do not want to include Sundays.

    I want to display Mondays through Saturday only.

     

    Is this possible? How do I approach this?

    Many thanks!!

    Wednesday, May 14, 2014 1:10 PM

Answers

  • User-1416423428 posted

    You can make Sundays not clickable, and color it with a grayed out text. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 14, 2014 1:26 PM
  • User-821857111 posted

    Something like this should get you started:

    @{
        DateTime today = DateTime.Today;
        var thisMonth =  Enumerable.Range(1, DateTime.DaysInMonth(today.Year, today.Month)) 
                        .Select(day => new DateTime(today.Year, today.Month, day)) 
                        .ToList();
    }
    
    <!DOCTYPE html>
    
    <html lang="en">
        <head>
            <meta charset="utf-8" />
            <title></title>
        </head>
        <body>
            @foreach(var day in thisMonth){
                if(day.DayOfWeek != DayOfWeek.Sunday){
                    <div>@day.DayOfWeek.ToString()</div>
                }
            }
        </body>
    </html>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 14, 2014 2:48 PM

All replies

  • User-1416423428 posted

    You can make Sundays not clickable, and color it with a grayed out text. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 14, 2014 1:26 PM
  • User-821857111 posted

    Something like this should get you started:

    @{
        DateTime today = DateTime.Today;
        var thisMonth =  Enumerable.Range(1, DateTime.DaysInMonth(today.Year, today.Month)) 
                        .Select(day => new DateTime(today.Year, today.Month, day)) 
                        .ToList();
    }
    
    <!DOCTYPE html>
    
    <html lang="en">
        <head>
            <meta charset="utf-8" />
            <title></title>
        </head>
        <body>
            @foreach(var day in thisMonth){
                if(day.DayOfWeek != DayOfWeek.Sunday){
                    <div>@day.DayOfWeek.ToString()</div>
                }
            }
        </body>
    </html>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 14, 2014 2:48 PM
  • User1771308999 posted

    Thanks!

    Thursday, May 15, 2014 11:13 AM