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

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

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

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

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

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 5091

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 61k
Author
Asked: November 27, 20242024-11-27T06:01:07+00:00 2024-11-27T06:01:07+00:00

Project Two: Calendar

  • 61k

Once upon a time we've build a calendar and it was working great! Well, up until the moment a whole month disappeared from it. We had January, February, March, May, July, August, a couple of Septembers… Yeah, it was wild, almost as bad as the AI generated one on this article's poster! The problem was that we used a third party library and despite our best efforts we failed to find the issue causing the bug. I wish I had a ready calendar skeleton back then – would save us a lot of time!

And hence I suggest you build one for yourself. Working with dates is all fun and games till timezones come into play, so be mindful of that whenever you do – and, judging by my own experience, calendars, date inputs, launch dates and schedules – are features I had almost in every project.

Calendar view: requirements & recipe

As a user I want to be able see a calendar for a selected month and year, so that I could see day of the week of the date in question.

Here's an example how this view could like:

Calendar from December 1, 2023 to December 31, 2023 in terminal with December 2 (current date) highlighted

Of course, you're free to implement it in HTML, like normal people, or you could follow my strange desire to make it a terminal view – it's up to you.

However, there are some requirements to keep in mind:

Requirements

  1. Calendar should show week days with the order in accordance with the locale of the user.
  2. All rows should have exactly 7 cells, padded with empty elements or faded out dates from the previous/next month.
  3. February should have a proper amount of days for leap and regular years alike.
  4. Current date should be highlighted.
  5. Think about accessibility: how should screen readers read your calendar?

Recipe

  1. Start with a static markup for the current month and year.
  2. Ensure that markup is accessible and semantic, e.g. with the help of Lighthouse
  3. Write a function that would create a list of dates for a provided month and year. I highly recommend writing some tests, especially around leap year logic.
  4. Write a function that would split days into rows for the order of weekdays you're most comfortable with (e.g. when week starts from Sunday). Ensure that all rows have exactly 7 elements.
  5. Adjust the previous function to work for the other case (e.g. when week starts from Monday).
  6. Create a function that would render the calendar using your favourite framework (or none).
  7. Highlight current date.
  8. Profit.

Hints

Almost any high-level language has a Date abstraction in the standard library: you can use it not only to construct proper dates, but also to verify the ones that aren't.
For example setting a day to 31 in a month that has only 30 days wouldn't work – and that could help you determine how many days a month has. Or setting a date to a 0 would result in the last day of the previous month.

Have fun!

Hard mode: Dates range input

There's a built-in HTML <input type="date" .../>, but unfortunately it doesn't support selection of a. range of dates. Selecting two dates from two inputs is also an option and is great for accessibility, but unfortunately it doesn't always fit into a page design.

Therefore, you could create a text input that would allow user to enter dates as December, 1 - December, 31 2023 or 1.12.2023 - 31.12.2023 and render this selection on a calendar.

A good input should be able to validate the dates, for example that start date is before the end date and that both are valid dates that can be parsed.

Share your creations and feedback and see you tomorrow!

Liked the idea a lot and would love to have it all year long?

Buy Me A Coffee

beginnerschallengecodingquokkawebdev
  • 0 0 Answers
  • 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

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 1k
  • Popular
  • Answers
  • Author

    How to ensure that all the routes on my Symfony ...

    • 0 Answers
  • Author

    Insights into Forms in Flask

    • 0 Answers
  • Author

    Kick Start Your Next Project With Holo Theme

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

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

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

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.