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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:28:52+00:00 2026-05-14T03:28:52+00:00

So I am using a scripting language with c++-like syntax, and I am trying

  • 0

So I am using a scripting language with c++-like syntax, and I am trying to think of the best way to check if a date is within range. The problem I am running into is that if the current day is in a new month, the check is failing.

Here is what my code looks like:

if(iMonth >= iStartMonth && iMonth <= iEndMonth)
{
    if(iDay >= iStartDay && iDay <= iEndDay)
    {
        if(iYear >= iStartYear && iYear <= iEndYear)
        {
                bEnabled = true;
                return;

When I have something like this:

    Start date: 3 27 2010
    End Date: 4 15 2010
    Current Date: 3 31 2010

The day check fails because if (iDay <= iEndDay) does not pass. The scripting language doesn’t have a lot of time related functions, and I can’t compare timestamps because I’m allowing users to put like “03:27:2010” and “04:15:2010” as start/end dates in a config file. I’m assuming I am just not thinking straight and missing an easy fix.

  • 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-14T03:28:52+00:00Added an answer on May 14, 2026 at 3:28 am

    You should really use boost::DateTime instead of attempting to rewrite the wheel (which when the wheel is a date/time framework it’s not as trivial as it may seem). This only if the code you pasted is C++ and not your scripting language (it wasn’t clear). Also may I suggest to use Lua instead? 🙂


    Anyway the problem is here:

    if(iDay >= iStartDay && iDay <= iEndDay)
    

    You should only check this if iMonth == iStartMonth, and the same for the end month. Otherwise iDay = 31, iEndDay = 15 and 31 <= 15 will fail.

    Also you should check for the year first, then the month, then the day.

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

Sidebar

Related Questions

Trying to write a windows speech recognition macro. Written using XML and scripting language
I would like to edit SVG files using some scripting language (preferably Python). In
Preferably using a scripting language like Perl or Python, but if I have to
LSL (Linden Scripting Language) allows for various particle effects using the llParticleSystem function. What
I'm makin' a scripting language interpreter using PHP. I have this code in that
Hi Im using Ruby as a scripting language. Not for web development, but to
I am using javax.scripting to add support for running arbitrary user-uploaded JavaScripts on the
I'm new in using scripting language. I come across 2 scripting languages called Perl
I've been using Ruby as my main scripting language for years but switched to
I like using Python, because of the easy-to-learn syntax, however, I recently learned it

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.